3 ms·
CSS Variables: Coming Soon to a Browser Near You
- ssharp 19y agoThis is something that would be very convenient. However, like most everything else related to web browsers, you constantly have to deal with backwards computability across multiple browsers. So this is just going to end up being ONE more thing that CSS coders have to be aware of. Hurray for CSS variable adoption being available to 90% of browsers in 2015!
- wind 19y agoIndeed. I think CSS shouldn't have variables. You should use a server-side program dynamically creating your CSS, perhaps, but CSS variables seems like more trouble than it's worth.
- Hexstream 19y agoI agree about using a server-side program to dynamically create CSS, but I still think it would be beneficial to have CSS variables. First, having native support for variables in CSS would eventually simplify the implementation of a proper (separation of variables from declarations among other things) "CSS compiler". It would also promote a better style of CSS because I don't think very many people use a framework with CSS variable/declaration separation. Second, in theory CSS is the domain of designers and they presumably use "standard" tools to edit CSS directly so they don't have variable support I'm guessing?... I'm sure we could be surprised how much CSS is edited by hand.
- jrockway 19y agoI agree. At the very least, "variables" should be implemented with multistage processing like MetaLua or Template Haskell. Really, I just want to say something like this: foo = { background-color: #coffee; margin: 42; } bar.span { ,foo; something-else } baz.span { ,foo; something-else } I know I can do this with HTML (apply more classes), but I can envision cases where this is less hackish (or more natural, anyway). Edit: the MetaOCaml people have some good reading about multistage programming: http://www.cs.rice.edu/~taha/MSP/ http://www.cs.rice.edu/~taha/MSP/