A Vote for CSS Variables
piehead.com
piehead.com
Of course, the CSSWG will no doubt create a solution that is both absurd in it's complexity, and limited in it's use. For example, constants defined with css-constant('foo', 'bar') instead of $foo: bar
The issue with sigil is that they risk conflicting with (and making more complex the parsing of) selectors. `$` used to be coopted by the Selectors Level 4 draft spec in order to select a non-tail subject for instance (it's apparently been changed to the `!` suffix).
Not that I like what they picked any more than you do (the spec is currently using the `data-` prefix for definition and `data()` for dereference, likely in keeping with HTML5's `data-` attributes)
See also Variable (mathematics) [1] vs. Variable (computer science) [2].
[1] https://secure.wikimedia.org/wikipedia/en/wiki/Variable_%28m... [2] https://secure.wikimedia.org/wikipedia/en/wiki/Variable_%28c...
Variables are not logic. Once CSS seizes being declarative and starts becoming a programming language, I think we might start seeing problems, but the author is not suggesting adding an if-statement to CSS (one might argue that media queries are already conditional enough).
I'm a designer, by the way.
The proper name for a web designer who can't write HTML+CSS is "artist".
1) is able to write valid cross-browser CSS ready for deployment without developer tweaking
2) would not understand basic logical constructs such as CSS Constants.
does not, in fact, exist. At least, I have never met one.
Think of it like this, imagine there is a sort of spectrum for capability of abstract logical/mathematical related thought. Roughly, on one extreme end there's someone who is so intuitive practical you wouldn't trust to properly split a dinner bill (this is not a "designer stereotype" btw, but an example of the very extreme end of the scale), in between there's doing calculations, solving simple equations, writing CSS, writing CSS-with-constants, using a templating language, doing actual coding, hardcore coding genius, and at the far end there's Neo who can stop bullets with his mind by wearing the right kind of shades and longcoat.
Your fear of "having too much logic and driving designers away" is only valid if the majority of web-designers fall right between "capable of writing CSS" and "capable of writing CSS with constants". Sorry but that's a rather narrow range and I'm not buying it.
And the few designers that happen to fall exactly in that range will either have to write CSS without constants (which is fine), or learn to deal with it.
[1] http://dev.w3.org/csswg/selectors4/#matches [2] http://dev.w3.org/csswg/selectors4/#idref-combinators [3] https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shado...
Part of the problem is that CSS And rich internet applications can't really properly coexist - they do now, because that's part of how we work, but as time goes on the amount of lifting we're going to want to do with JavaScript is only going to continue to increase.
Reading the Introduction section, I get the impression that Shadow DOM is supposed to help with creating widget-based UIs, but if we're at that point, why are we still using the text/document-focused DOM instead of creating a new abstraction that is better suited for UI (though the insertion point concept looks potentially useful)?
As for the rest of CSS, I've really been rolling around to "just create a canonical JS binding and be done with it"; it's headed headlong into the Turing Tarpit and as long as it's going to end up there one might as well use a language designed to live in it.
Every concept that is part of "constant" is fundamental to understanding CSS in the first place.
Seeing something like #046e08 everywhere scared me much more as a new developer than something as simple as "let green1 = #046e08" would have.
It merely makes maintenance much, much easier.
Welcome to the real world. It's time to upskill.
Side note: Developers may be inferior designers, but that does not make them inferior coders, since by their nature, that is what they do day in, day out. I am not a designer, I am not a front end guy, but my html/css/javascript is a lot better quality and reusable than I have seen come out of any design agency. We won't even go into having any consideration of the selectors they use and any rendering speed they may have...
What CSS really needs is an actual layout module in the specification (instead of the hacks we still use to this day to execute the most simple of layouts).
With all that said, I do think variables are a great idea.
Why are standards committees dictating developer workflow? We should be able to swap in our own parser and UI framework (which is what DOM is) that fits the specific website/webapp needs best. Not reinventing the wheel, of course - things would naturally coalesce into ubiquitous standard libraries, but a bit more competitively.
New styling possibilities would be more interesting, e.g layer blend modes.
Unless maybe you are living in the 80s and using a Spectrum 48k?
Speed. Christ.
It makes no difference, these are proposal for constants so it's trivial substitution. Furthermore by avoiding repeating the same value over and over again CSS variables likely reduce the file's size.