Hacker News new | ask | show | jobs
by filleduchaos 854 days ago
The entire industry did, in fact, do it wrong for decades.

The problem was never that CSS - a DSL that exposed more of the browser's layout and painting engine than HTML did - was somehow less capable than HTML alone at implementing the same design.

The actual problem was that the requirements of designing for the web changed very rapidly. Take GP's example of text centred in a 600px yellow square; again it's not that it was soooo hard to achieve that specific layout with CSS. It was that they were trying to accomplish layouts a lot more complicated than that, often without breaking those layouts down well enough to be expressed in terms of the available layout algorithms. The longterm solution to this was of course for browsers to provide implementations of more advanced algorithms (like flex and grid) to match more advanced layout requirements, but that process was dragged out for far too long and eventually landed in a far too fragmented manner - a massive mistake.

And on top of that, it's not as if the existing layout algorithms were particularly incapable; on the contrary, they are well documented and you can get very far with them alone. So many questions ("how do you center a div??", "where are my margins??", "why isn't z-index working??") have answers that are quite apparent if you're familiar with the spec and thus understand what the browser is actually doing when it lays out your elements. But how many devs even know that e.g. stacking contexts exist, to talk of when they are created?

It's not as if it's even their fault, it's yet another thing that basically the entire industry did wrong for years. How many web design/frontend tutorials really explain anything about the CSS spec or about how UI rendering works in general, as opposed to just shoving arcane styling incantations at learners to cram? It's a failing of the industry that even today you have to go quite a bit off the beaten path to actually learn CSS (and HTML itself, while we're at it). Imagine if we taught any other language in the same haphazard manner! Just because they aren't technically programming languages doesn't mean that they're not worth proper instruction.

1 comments

If you look at any of the suggestions in the article, each uses at least one feature that came out in the late 2010s. Add a couple of years until initial bugs were fixed (which were there), and until browser adoption is high enough that older browsers can be ignored.

Back then I could whip up a dozen centering solutions, but not a single one that worked across all browsers in all cases. Tables just worked.

You're so wrong about the history that it makes me assume that you started webdev after this compatibility mess was fixed. It was truly disgusting. If anyone had found a solution back then everyone would have slurped it up immediately.

Ha, ya you're right. My memory on table-cell was fuzzy and didn't bother looking into before making some other responses. IE 6 and 7 had no support for it and Firefox had partial support until 2008. I'm just looking at caniuse, of course, I don't remember what Netscape supported.