CSS variables are go!

Do variables even have a place in CSS?

In a post I wrote almost a year ago (and in the ensuing comments), I pondered the possibility of someday being able to define variables natively in a CSS document without the use of server-side scripting.

Well it seems that in their most recent nightly build, WebKit has added support for this.

@variables {
    CorporateLogoBGColor: #fe8d12;
}
div.logoContainer {
    background-color: var(CorporateLogoBGColor);
}

I'm not sure if this is based on any particular official CSS3 recommendation or if its something that WebKit has just grabbed and ran with in the hope of it going mainstream, but its certainly a step in the right direction.


1 comment on ‘CSS variables are go!’

  1. Nothing official yet. Hyatt just writes code faster than he writes specs. :) The spec and WebKit will probably morph a lot until the spec stabilizes.

Comments are closed

Comments on this post have been closed. If you would like to contact me about this post or for any reason, please get in touch.