There have always been a ton of common, simple things that CSS just didn't support, or required bizarre hacks for -- like reusing "floats" intended for inset images as the basis for layout. Over the years it's gotten better, but if you've been doing this for 15+ years, surely you remember the old horrors. I don't want to have to insert "clear: both;" at the start of every new section ever again...
Not to mention that back in the day, browsers weren't nearly as standards-compliant, so your designs would just show up wrong in some browsers, and you'd rip your hair out trying to write CSS that would work in all of them.
For example, `margin: auto` expands left/right margins but not top/bottom margins.
....and 50 other such cases.
And yet when flexbox was created, there was no horizonal/vertical difference.
But I agree with the basic sentiment. The small irregular things [1] make it really weird to get, but once you'll get it, it's crazy cool. However, that does not make a language great.
Text goes from left to right, then wraps back around to the left moving vertically down (obviously this is for RTL languages; adjust for different writing systems). So this means that there’s a left and a right edge, which means that centring something horizontally makes sense – the mid-point between those edges is the centre. But it also means that there’s no real bottom imposed upon the text – the text starts at the top and just keeps flowing downward until it runs out. So centring something vertically isn’t the same sort of thing as centring something horizontally.
Or to put it another way, the horizontal edges are imposed by something external to the content (often the viewport), and the bottom vertical edge is defined by the length of the content. The two axes are treated differently by CSS because they are fundamentally different.
If our writing system were turned 90° on its side and we wrote downward until we reached the bottom of the page then moved back to the top and right one line, like some traditional Asian writing systems, our browsers would scroll left and right by default and you would be complaining that `margin auto` expands top/bottom margins but not left/right margins. It’s the writing system that works this way, CSS just does what is sensible for that writing system.
Later on, more layout systems like grid were introduced by CSS that weren’t based upon the flow of text, but things made logical sense before then as well.
https://twitter.com/sw_unscripted/status/1730707950518309109
> later other systems were introduced that weren't inconsistent
yea, that's about right, except the maybe part
I knew about HTML/CSS around 2004, and knew about C++ in late 2005 - so kind of about the same time, almost 20 years ago.
Both of them have evolved and have had substantial additions since then, but I can't imagine that I'd say "C++ is easy!" if I kept putting my nose on it all this years - even back then the pointers thing (and pointers to pointers, to be more specific... won't even think about all its new stuff) was absurdly difficult to understand for me. Whereas the concepts behind CSS were much easier to understand, the difficulty I found about it (and what I suspect people say it's "difficult") was in its implementation - styling for IE was a living hell, and after that all the gibberish we had to do to support -moz, -webkit, -o, -ms and co, and now all the platforms, modes, layers, medias and all of that we have to take care of. But I repeat - it's not that the core of what CSS does or how it works is the difficult part.
As for why it's confusing, I think it's due to the inconsistencies of the language. https://wiki.csswg.org/ideas/mistakes
Also, you have to know the rules of the game to be proficient at css, and the rules will change from underneath you based on context, and unless you're in this space often it will often feel like voodoo and a constant search of "why isn't this working here when it works there... oh, because the parent is using position x". Also messing with css for over 15 years I know most of the rules of the game, and it has definitely gotten easier over time, but every now and then something will still surprise me.
Not to mention game devs doing GPU stuff. I regret committing to programming with 30yo, in my 20s I probably would have the time and energy to learn much more.
None of that is universal, of course, and it’s not like CSS is perfect but the worst code I’ve seen was written in near-contempt by, for example, some dude who wrote many thousands of lines of … not brilliant … code to make a Java display framework because he refused to learn how CSS works. I was called in to that for performance reasons because if you don’t understand classes, you can end up with 20MB HTML responses with the same inline styles everywhere. That was an outlier but I’ve seen a lot of similar attitudes where someone shipped 4MB of JavaScript to avoid learning CSS positioning or tried to get a designer to edit their code because they thought adding IDs or making semantic, accessible markup was beneath them. One interesting social dynamic there has been the guys who simultaneously refused to deal with front end stuff but also didn’t think it should pay well, often with more that a whiff of sexism given how designer was coded female at those places.
That’s improved in some ways as front end work became more central in the SPA era but it’s still pretty easy to find people who’ll deploy enormous amounts of code to avoid using a builtin browser feature or whine about how “the DOM” is too slow as if it’s the browser’s fault they’re using React.
I mean... yeah?
That's the benefit of doing something for 15 years, it's intuitive and no longer confusing.