News for hackers. Stuff that matters.
Re:How Browsers Lay Out Web Pages by helsinkiandrew on Tuesday April 06, 2021 @04:56AM (#26709637)
This is excellent. However much effort I've put in I've always found HTML or rather CSS impenetrable. When doing something a little more complex I will often end up with something that works (or breaks) without fully understanding why.

Are there any other good references that give a good underlying understanding of HTML/CSS without just giving examples of the various elements?

Re:How Browsers Lay Out Web Pages by macspoofing on Tuesday April 06, 2021 @07:49AM (#26710719)
>Are there any other good references that give a good underlying understanding of HTML/CSS without just giving examples of the various elements?

Yeah. The W3C spec.

A few years ago (before css flexbox and grid were really a thing), I was in your shoes. Anytime I needed to do something non trivial, I'd have to find some snippet from some tutorial site that would kind of fit with what I was looking for. At some point I got tired of that and just read the W3C specification. That's when I finally got the CSS layout manager. The specification was very accessible and explained exactly the layout rules. For example, here's the spec on the CSS box model: https://www.w3.org/TR/css-box-3/

Now that flexbox and grid are universally supported in modern browsers, css is actually quite easy.

Re:How Browsers Lay Out Web Pages by andeee23 on Tuesday April 06, 2021 @05:35AM (#26709888)
Don't have any references for you but maybe I can give some perspective on it.

The things that still trip me up with CSS after a few years of full time frontend work are the following:

1. Dynamic 2D stuff

CSS kinda sucks for most 2D dynamic layouts. Especially when you have heights that are dependent on widths or the other way around. With CSS grid and the upcoming aspect-ratio things are better but I still run into some limitations in especially dynamic web apps / data visualizations I make and I usually resort to calculating the widths/heights in javascript so I can have full control.

2. Going into the third dimension

I'm not a big fan of the z-index / position absolute / relative stuff going on in css. I'm not sure what a better way would look like, but every so often I run into weird issues where a parent somewhere is relative and it messes up an element I'm trying to absolutely position.

Most things can be worked around but it's still annoying and usually take longer than what I feel they should.

Apart from these, most of the quirks of CSS are very mild and can be worked around easily. I actually find writing CSS quite enjoyable day to day.

Re:How Browsers Lay Out Web Pages by pavpanchekha on Tuesday April 06, 2021 @11:50AM (#26713349)
Author here. Unfortunately, a lot of this "conceptual" content doesn't really exist, just because there aren't that many people who work on web browsers, plus it takes a lot of work to get a comprehensive view.

I wrote up this guide about CSS floats, for example: https://pavpanchekha.com/blog/css-floats.html It is just about complete, but it also took me about a year of work to get that understanding (from reading the spec, reading browser code, trying many many examples) and it lead to a published paper. And even then, it doesn't talk about negative top margins or refer to actual implementations!

Re:How Browsers Lay Out Web Pages by tjoekbezoer on Tuesday April 06, 2021 @05:54AM (#26709995)
I'd say a good start would be:

* Stacking context [1] — how individual layers interact with eachother to form a layout.

* Box model [2] — the most important properties that give an individual element its dimensions.

[1]: https://tiffanybbrown.com/2015/09/css-stacking-contexts-wtf/

[2]: https://css-tricks.com/the-css-box-model/

Re:How Browsers Lay Out Web Pages by huy-nguyen on Tuesday April 06, 2021 @07:49AM (#26710722)
CSS The Definitive Guide by Eric Meyer is a deep dive book into all aspects of modern CSS by an expert.