W3C Decisions on CSS Variables (Accepting Comments)
xanthir.com
xanthir.com
Coming from LESS this seemed strange at first, but upon reflection it makes a ton of sense, and provides for fantastic flexibility.
Now to really make this useful, we just need mathematical operators for distance values (12px - 2px) and functions like darken() and lighten() on color values... or is that being proposed somewhere too?
Color manipulation will be in Colors level 4, whenever I get the time to work on it (probably early next year).
:root{
var-myforecolor: red;
var-mybackcolor: blue;
}
h1{
color: $myforecolor;
background: $mybackcolor;
}
This covers 80% of all cases, leaving parent-vars and cascading-vars as edge cases. Good to have them just in case.Bring it on!
(The rationale seems sensible to me, for what it's worth.)
Then, if browser makers didn't implement appearances the same way, we could point to the standard and ask why.