Live data from Hacker News

Why is CSS the way it is?

increment.com

121–130 of 173 posts

Re: Why is CSS the way it is?

#121
post #96
post #87

Earlier quoted context omitted.

Don't forget the gigabytes of code spent trying to work around the cascade and produce some kind of framework for styling "components" that doesn't leak crazy state from the enclosing context (but does inherit the good stuff). The "cascade" was, for sure, a mistake. Not being in this world, though, I do wonder why there's been no real attempt to fix this from the ground up? I mean... it wouldn't really be "hard" to c…

> The "cascade" was, for sure, a mistake. Aren't global styles only possible because of the cascade and the child elements inheriting from parent elements? Without cascade, wouldn't you have to re-declare your font size and font family, and line-height, etc. on every element of your markup?

The cascade is not inheritance. The cascade is deciding the order to apply rules/stylesheets in, and which rule applies here:

html:

    Blah
css:

    a { color: red; }
    div a { color: blue; }
Where the font color ends up being blue because `div a` is more specific than `a`.

Re: Why is CSS the way it is?

#122

I've found that since using utility/functional CSS in the form of Tailwind that I actually enjoy making UI's now. Coupled with componentization in the form of a JS framework like Vue, I don't need to stress over CSS anymore. No more LESS or SASS, no more .header-container, .header-parent-inner crap. https://adamwathan.me/css-utility-classes-and-separation-of-... I'm sure some puritan naysayer will disagree but whatev…

I also find utility CSS libraries like Tailwind help address the difficulty in naming CSS styles. Once your team learns the common design system implemented by Tailwind everyone is speaking the same language.

Re: Why is CSS the way it is?

#123

Earlier quoted context omitted.

Given my thoughts (and recent experience) was shaped by something like Elm-UI - see: https://www.youtube.com/watch?v=Ie-gqwSHQr0 If you have the time to learn CSS, you have the time to learn anything else. ;)

Though any self-respecting web developer should sit down and learn CSS. Part of the problem with CSS is that we seem to relegate it to something we don't need to learn. "Well, it's just CSS. I'm a developer !" And then we complain when we don't understand it or when our jerry-built sequence of StackOverflow copy-and-pastes is a clusterfuck to deal with. I myself realized I was working off knowledge I read in a CSS bo…

It's a terrible waste of time if you can find a good alternative. Luckily Elm-UI is exactly that.

Edit: of course it's worthwhile to learn enough CSS to understand more or less what it does since it's so pervasive. I mean that using it as the main way to lay out pages is a frustrating experience in many cases.

Re: Why is CSS the way it is?

#124
post #90

Earlier quoted context omitted.

Can we just start over on the entire web stack? 1. create a serious styling and scripting framework, basically React as a language since people seem to like it 2. implement an interpreter in WASM. Ship the interpreter with the website unless the browser says not to 3. over time, build the interpreter into the browser

there's canvas, you can already write apps that target it both in unity and Godot, the latter spring a wealth of languages

Question: how do these engines address accessibility issues for, say, a holiday booking site that uses the canvas element for its entire UI?

Re: Why is CSS the way it is?

#125
We need a time travel machine to remove the CSS and add Objective-J. Objective-J is great for people who don't want HTML / CSS hell. I asked the Objective-J author about native browser support as JS/HTML/CSS because performance was matter 10 years ago. And got the answer is "they wil never browser builtin other than JS/HTML/CSS". And now we have multiple new ecosystems, template engines, package managers, languages, reactive frameworks, and other 15 standards

Re: Why is CSS the way it is?

#126
post #24

Earlier quoted context omitted.

CSS clicked for me from the very start. It was always fun, I never had problems with it (aside from the browser bugs, of course). Maybe problem others have with it is not because of the nature of the CSS, but because of people ignoring that nature and refusing to learn it and trying to carry over their experience with other technologies to CSS.

You were never asked to implement a simple three column layout in CSS where the center column expands with the screen size? That’s often the first thing people were asked to do in the early days after being asked to replace the old table based layout. CSS grid/flexbox took way too long to arrive.

I did lot of things, and even had to implement pixel perfect designs in IE5. Honestly, those challenges were a part of the fun. Not sure I'd want to go through the same again, but it was fun back then.

Re: Why is CSS the way it is?

#127
post #96

Earlier quoted context omitted.

> The "cascade" was, for sure, a mistake. Aren't global styles only possible because of the cascade and the child elements inheriting from parent elements? Without cascade, wouldn't you have to re-declare your font size and font family, and line-height, etc. on every element of your markup?

The cascade is not inheritance. The cascade is deciding the order to apply rules/stylesheets in, and which rule applies here: html: Blah css: a { color: red; } div a { color: blue; } Where the font color ends up being blue because `div a` is more specific than `a`.

I assume this is inheritance then?

    a { color: red; }
    div { color: blue; }
(Blah will be red now.)

(I have little knowledge of CSS.)

Re: Why is CSS the way it is?

#128
post #120

Earlier quoted context omitted.

If you're doing class='centered' or class='with_padding', I don't see any reason not to just do style='align-self:center;' or style='padding: 1rem;' instead. The class names communicate less (Is that centering the content of the element, or the element itself? Is that vertical or horizontal centering, or both? Is the text being centered?). And it doesn't allow you to make sitewide changes like a semantic class does (…

Typically you have a design system that keeps things consistent. So you would have maybe 5-6 different padding sizes, eg padding-s, padding-xl or whatever. That's why you don't just do style='padding: 1rem;'. Instead you assign a predefined padding class that's defined by your design system. As for me using .centered, it was just a quick example, and you took it in bad faith and now are nitpicking minor details. Site…

> Typically you have a design system that keeps things consistent. So you would have maybe 5-6 different padding sizes, eg padding-s, padding-xl or whatever. That's why you don't just do style='padding: 1rem;'.

Well, I'm not saying you should do style='padding: 1rem;', I'm saying that padding-s has all the downsides of mixing styles into your markup, with none of the clarity of just using inline CSS. The solution isn't to use inline CSS, it's to use semantic class names.

I can see the convenience of naming your padding sizes for consistency: that's what SASS inheritance does.

> As for me using .centered, it was just a quick example, and you took it in bad faith and now are nitpicking minor details.

1. Cool it. Nobody is attacking you, you don't need to attack me. We're discussing ideas, not each others' faith.

2. I've encountered this antipattern in production code, so regardless of whether you were actually proposing it as a serious idea, some people do take this idea seriously, so it needs to be addressed. The problems I pointed out aren't theoretical: I've dealt with them in practice.

Re: Why is CSS the way it is?

#129

Earlier quoted context omitted.

If you're doing class='centered' or class='with_padding', I don't see any reason not to just do style='align-self:center;' or style='padding: 1rem;' instead. The class names communicate less (Is that centering the content of the element, or the element itself? Is that vertical or horizontal centering, or both? Is the text being centered?). And it doesn't allow you to make sitewide changes like a semantic class does (…

This mixing of concerns was garbage and still is garbage, regardless of whether its popular now.

To be clear: putting `class='centered'` in your HTML is absolutely mixing concerns. That's exactly the problem I'm pointing out.

Re: Why is CSS the way it is?

#130

IMHO this article inadvertently shows why people hated CSS at the start. He spends a lot of time talking about color space conversions that few developers care about and Unicode filtering that even fewer people know about but glosses over basic layout by mentioning how floats allow for better inline images. It’s like the designers didn’t even think about layout because that problem was already solved with HTML tables…

not even inline blocks, that shit didn't work in ie6, i was fucking ecstatic once i could use inline-blocks
Post reply on HN