3 ms·
Years ago I came to the conclusion that CSS should be treated as just a place to dump reusable styles, and all logic should be in the html/templating language.
by isleyaardvark 4y ago
Years ago I came to the conclusion that CSS should be treated as just a place to dump reusable styles, and all logic should be in the html/templating language. It's made my life significantly easier.
- alwillis 4y ago> Years ago I came to the conclusion that CSS should be treated as just a place to dump reusable styles, and all logic should be in the html/templating language. Coding like this removes so much of the flexibility and power of CSS. The reason we have media queries and now container queries and style queries is because HTML is for structure and CSS is for presentation and the state of things being presented. If a user selects high contrast mode because they're sight impaired, that's a state issue that has to be handled by CSS; HTML can't help you here: @media screen and (forced-colors: active) { … … } To anyone who's learned CSS properly sees this as "IF the user wants forced-colors mode (previously high-contrast mode), THEN execute the selectors between the braces." This is certainly cleaner than an explicit IF/THEN construct for this particular feature.
- valenterry 4y agoI recently tried that and it simply doesn't work because even in the latest version CSS is unusable for anything remotely complex or without repeating code. Gave up and am doing it like OP now. CSS MUST become a proper programming language (or at least non-turing-complete configuration language like dhall) to solve this.
- nonethewiser 4y ago> HTML is for structure and CSS is for presentation These really arent decoupled.