3 ms·
Absolutely agree, although CSS has slowly become more and more like a programming language over time, so it's understandable that people have this confusion.
by oneeyedpigeon 10mo ago
Absolutely agree, although CSS has slowly become more and more like a programming language over time, so it's understandable that people have this confusion.
- marcosdumay 10mo agoCSS isn't "like" a programming language. It is a programming language. It's just not one based on states, mutability, and variables. Even the things that use the `var` keyword are constants, not variables. (But then, don't read that as being against scoped rules. The fact that all rules are global to the document is bad. We can emulate scopes with specific selectors, but that's the kind of thing a language is supposed to help with.)
- the_other 10mo ago> constants Constants which you can redefine/shadow in scopes, and change the values of at runtime via JS. They seem like variables to me.
- marcosdumay 10mo ago> and change the values of at runtime via JS No, you can't. You can set a new value and reevaluate everything.
- the_other 10mo agoI’m dumb and don’t understand the distinction you’re making. elem.style.setProperty(‘—var-name’, newValue); … will set a new value for the “constant”. The element will rerender with the new value. You can animate/automate these changes and the element will continue to rerebder with the updated value. To me, that justifies the name “variable” from the perspective of the CSS.