Forum Moderators: not2easy

Message Too Old, No Replies

Variables in css

Can we use variables in css files

         

Murali

12:55 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



i need something like following.

-------------------------------------
variable myColor = #eeeeee

body {
backgroundColor : myColor;
}

p {
color: myColor;
}
-------------------------------------

so that i can just change the variable value, instead of chaging color value in all the places.

any solution?

thanks in advance

Murali

benihana

1:01 pm on Aug 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



php can do this (as can asp and others),

You can reference a .php file in your style tags (or set the server to parse css as php).

You have to add


<?php header( "Content-Type: text/css" );?>

at the top of the file, or firefox wont play nice. ;)

syff

3:03 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



I'd recommend using Shaun Inman's excellent CSS Server-side constants method.

More information can be found at [shauninman.com...]