4 ms·
Its still not clear to me why native CSS doesn't/shouldn't support variables.
by fergie 9y ago
Its still not clear to me why native CSS doesn't/shouldn't support variables.
- electrotype 9y agoIt does : https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_v...
- amptorn 9y agoBecause > CSS style sheets are short. They are not much bigger than one editor window. Very few people (only professional designers, it seems) write style sheets longer than a hundred lines. <https://www.w3.org/People/Bos/CSS-variables> https://www.w3.org/People/Bos/CSS-variables>
- mcintyre1994 9y agoI'm pretty skeptical of that quote: HN's CSS is pretty minimal and comes in at 174 lines: https://news.ycombinator.com/news.css https://news.ycombinator.com/news.css It seems to be based on the W3C website where apparently 90% of style sheets are <163 lines, but I'd like to see that distribution over the internet as a whole.
- jrimbault 9y agoSidenote: the html markup of HN doesn't lend itself to "clean" css (whatever that means). Hence maybe why it's bit over that 163 mark line. Nested tables inside nested tables, with styles inlined.
- mcintyre1994 9y agoTrue, but moving styles from inline or moving from tables would almost definitely add more CSS lines.
- amptorn 9y agoIt doesn't matter whether the quote is accurate now or even whether it was accurate in 2008 when it was originally written. What matters was that this formed the rationale for keeping variables out of CSS.
- mcintyre1994 9y agoAh I didn't catch it was written in 2008 before Bootstrap :) I'd say that time gap is significant though because CSS does have variables now.
- sureaboutthis 9y agoThough variables has been added as a recent thing, people need to remember that CSS is not a programming language.
- astura 9y agoJust because it's not a programming language doesn't mean it "shouldn't" have variables. It just makes sense to be able to, for example, declare all the colors you're going to use multiple times in your document ahead of time so you can say "highlighted-area" instead of "#ADD8E6," same as saying "black" instead of #000, it's just "black" is built into CSS itself. It just gives things a semantic and reusable meaning. For a non-text example, it's similar to how you can create a theme in MS Office and it shows you "theme colors" first in the color selection tool.
- sureaboutthis 9y agoWhat does what you said have to do with anything I said?