Re: CSS Variables

On 06.02.2011 01:34, Tab Atkins Jr. wrote:
 > A few weeks ago I gave a talk about some experimental things some of
 > our teams at Chrome are working on.  (You can see the subsequent
 > blogpost at<http://www.xanthir.com/blog/b49w0>.)  I obviously want to
 > bring all of them to the group soon, but I want to start on Variables,
 > being the simplest and most-requested feature.
 >
 > We've been arguing about CSS Variables for a long time, but could
 > never agree on how it was supposed to work.  This sucks for authors,
 > particularly as the rise of preprocessing frameworks like SASS have
 > shown just how popular and useful variables are in designing and
 > theming webpages and webapps, both large and small.  I and some other
 > Chrome engineers have put together a proposal for variables that is
 > very similar in nature to what glazou proposed in
 > <http://disruptive-innovations.com/zoo/cssvariables/>  (the syntax is a
 > bit different, but that's mostly a bikeshedding detail).
 >
...
 > The syntax isn't complex.  What we're going with so far is this:
 >
 > @var $foo red;
 > bar {
 >    color: $foo;
 > }

ignoring the question if variables should be included in browsers, just 
regarding that syntax:
What is wrong with the syntax proposed at 
http://disruptive-innovations.com/zoo/cssvariables/ you referred to?

@variables {
     foo: red
     }
bar {
     color: var(foo)
     background: var(foo) url(x.gif) no-repeat;
     }

would not introduce any new syntax/grammar, just a new @-rule and a new 
value "function". The ``$foo`` would change the parsing rules of CSS, 
would it not? Is that really worth it if there is another option which 
is working (and IMHO nice) too. Actually this is implemented in a kind 
of preprocessor in cssutils (Python CSS lib, 
http://code.google.com/p/cssutils/) and it I liked using this (obviously 
not being completely objective here ;).


Adding a syntax to the spec would be good just to prevent different 
syntaxes in different preprocessors currently available (if they use a 
CSS like syntax at all).

best regards
Chris

Received on Sunday, 6 February 2011 11:38:13 UTC