Thoughts on web development and technologies by Peter Gasston

CSS Variables proposal is released

I mentioned CSS Variables previously, and now the proposal has been published and I agree with authors Daniel Glazman and David Hyatt when they say:

We expect CSS Variables to receive a very positive feedback from both the Web authors’ community and browser vendors.

The syntax will be to declare the variables using the @variables at-rule, then calling them with the var() function:

@variables { keyColor: #f00; }
h1 { color: var(keyColor); }

That’s it. Beautifully simple, and I really, really look forward to seeing it implemented.

5 comments on
“CSS Variables proposal is released”

  1. Dave Woods - HTML, CSS, Web Design » CSS Variables [April 9th, 2008, 1:13 pm; Permalink]

    […] first heard the news from Peter’s blog over at Broken Links and thought it would be of great interested to most of the readers […]

  2. Arjan [April 9th, 2008, 5:47 pm; Permalink]

    It is nice, but not required for most websites. Most of the times a simple Find/Replace action in the texteditor is enough.

    I would enjoy it when browsers start to support the “CSS3 calc function”:http://www.w3.org/TR/css3-values/#calc .

    (By the way, your preview function breaks when I use an ampersand.)

  3. Arjan [April 9th, 2008, 5:49 pm; Permalink]

    Ah, and Textile seems to break when I use a hash in the URL of a link…

  4. Binny V A [April 9th, 2008, 6:14 pm; Permalink]

    I would have preferred something simpler/easier like $var_name - but then again, something is better than nothing.

  5. Peter [April 9th, 2008, 6:33 pm; Permalink]

    @ Arjan: It’s true that a search and replace would be useful in most cases, but not all; I think this is a very simple solution to cover all eventualities. And thanks for the info about the previews & Textile; I’ll look into it.

    @ Binny: Using a $ would be the better solution for anyone used to using programming languages, but the use of enclosing brackets is more consistent when using functions in CSS (src(), calc(), etc).

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Search