Tuesday, July 1, 2008

CSS Variables

How long have you wanted to name colors and such in your CSS instead of having to use search and replace (which breaks if you share the same colors ;) ?

We have a proposal thanks to Daniel Glazman and the ubiquitous David Hyatt.

Since the release of CSS Level 2 Recommendation ten years ago in may 1998, the Web authors' community has been requesting a way of defining variables in CSS. Variables allow to define stylesheet-wide values identified by a token and usable in all CSS declarations. If a value is often used in a stylesheet - a common example is the value of the color or background-color properties - it's then easy to update the whole stylesheet statically or dynamically modifying just one variable instead of modifying all style rules applying the property/value pair. We expect CSS Variables to receive a very positive feedback from both the Web authors' community and browser vendors.

With Dave on the author list, we can expect the following to work on WebKit sometime soon!

  1. @variables {
  2. CorporateLogoBGColor: #fe8d12;
  3. }
  4. div.logoContainer {
  5. background-color: var(CorporateLogoBGColor);
  6. }
via: ajaxian


Post a Comment

Subscribe to Post Comments [Atom]

<< Home