CSS variables

by saravana 2013-06-11 16:02:44

It's something that many people have been asking for and wanting for some time now and finally it looks like variables are going to be making their way into CSS.
CSS allows variables using Less or Sass witch are CSS Dynamic languages.
Variables:
Variables allow you to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code.

@color: #4D926F;
#header {
color: @color;
}
h2 {
color: @color;
}

Presumably using this method you’ll be able to declare all your colour scheme in a bunch of variables at the top of your CSS

@variables {
firstcolor: #f00;
secondcolor: #300;
thirdcolor: #300;
}

Drawbacks:
CSS is not a programming language. Adding variables will just increase the complexity of an already complex markup scheme. Adding variables also adds an extra step for parsing and executing the stylesheets client-side.

Tagged in:

1050
like
0
dislike
0
mail
flag

You must LOGIN to add comments