by charliebwrites · 2y ago · 0 comments
It seems like Browser makers, Languages creators, and developers all have a pretty strong incentive to solve such a fundamental, basic problem in web development to make the design experience easier.
Why haven’t these groups come together to make an easy solution to this? What am I missing?
The problem with designing and implementing application layouts for the Web is that it's such a dynamic medium. You can't ever rely on a particular viewport size, and you generally can't rely on content size either.
Like, just as a simple example: build me a page which has a white background and three blue boxes in the middle which contain white text saying "foo", "bar", and "Supercalifragilisticexpialidocious".
How big should these boxes be? Should they even be the same size? How should text wrap within them? How should the text itself be aligned within the boxes? When you say the "middle", do you mean centered vertically or horizontally? Are they laid out in a row or in a column? What's the expected behavior when the viewport size is too small to accommodate them? Should the boxes themselves wrap in some special way? Should they resize themselves?
This isn't even really splitting hairs or anything, it's just sort of the mindset you get into when you start working within a domain that's governed by *constraints* rather than specific sizes.
The most obvious example: horizontal and vertical centring are different because our writing system has a specific direction it flows in. You can’t just do the same thing for horizontal as for vertical because text doesn’t work that way.
I’ve been building websites longer than most (since 1994 in fact) and centring in CSS is definitely not as easy as it was with the <center> HTML. Not even close. If it were, there wouldn’t be this entire discussion to begin with.
I swear the amount of times topics like this come up and yet a small subset of developers, likely Stockholm syndromed into believing things are great, is ridiculous. The sooner people like yourself pull your head out of your arse and realise that the current status quo is unacceptable, the sooner web standards finally mature into something that doesn’t have more footguns than the worst of C and worst of Perl combined.
It's perfectly reasonable to ask a particularly language to make the easy things easy while still being powerful enough to make the hard things achievable. When it comes to CSS, or even web development in general, that isn't often the case. This discussion demonstrates that point too.
We're long overdue a redesign in my opinion.
https://developer.mozilla.org/en-US/docs/Learn/CSS/First_ste...
And yet it's not standardized[1], so if you implement it in a new layout engine you're left with reverse-engineering what other browsers do (a classic).
[1]: OK, I lied. It is standardized... in the HTML standard. https://html.spec.whatwg.org/multipage/rendering.html#align-...
Notice how it's not a stylesheet, not a presentational hint, just prose. It's because standard CSS can't do what browsers could since before its invention.
https://html.spec.whatwg.org/dev/obsolete.html#non-conformin...
Ok, maybe this will make my point clearer:
<center style="background-color: green">
<div align=right style="width: 10ch">
hello
</div>
</center>
To replicate this in standard CSS: <div style="background-color: red">
<div style="text-align: center; margin: 0 auto 0; width: fit-content">
<div style="text-align: right; width: 10ch">
hello
</div>
</div>
</div>
Or you can switch out of flow layout: <div style="background-color: red; display: grid; place-content: center">
<div style="text-align: right; width: 10ch">
hello
</div>
</div>
Ok, one semantic div less. But why can't I do this? <div style="block-align: center /* would act like text-align: -moz-center */">
<div style="width: 10ch; block-align: right /* would act like text-align: -moz-right */">
hello
</div>
</div>
If my browser understands the first variation, then getting it to understand
the last one is in all likelihood not much effort; it's just substituting
properties.The only reason it doesn't, is that the property does not exist in the standard. So you have to use non-semantic centers instead of semantic divs, but that's frowned upon, so you have to use grid layout even though you aren't making a grid, just centered flow.
I just wish it were standardized, considering it's already implemented in all browsers (in the forms text-align: -moz/-webkit-center).