Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

CSS Variables: Coming Soon to a Browser Near You

cssvar.jpgEver wished you could use variables in your stylesheets? Well, what may be the number one most requested feature for the next generation of CSS, finally has a formal proposal. The spec, put forth by Apple’s David Hyatt and and Daniel Glazman of Disruptive Innovations, would allow web designers to use variables in stylesheets.

For those that have never considered the idea, here’s why variables would be so useful: imagine you have a common font-color declaration that you apply to all sorts of elements in your stylesheet; using a variable you could define the color once, making it much easier to change in the future. Instead of hunting through your stylesheet looking for every place you used that color, you could just change one line of code to update every element that uses that variable.

Even better is this line from the proposed spec:

The definitions of variables should cross @import boundaries so variables can be contained in a standalone stylesheet and imported by all stylesheets needing them.

Which means that you could keep your variables in an entirely separate file and when you wanted to make a site-wide change, you’d just need to update the one file.

For now CSS variables are just a proposal and may undergo significant rewrites before they find their way into browsers. But given that David Hyatt, one of the key developers of Apple’s Safari browser, is one of the authors, we wouldn’t be surprised to see experimental support for variables turn up in a future Safari update.

[via Simon Willison]

See Also:

Post Comment Comments Permalink Print
Reddit Digg

 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year