user1866400
user1866400

Reputation:

Is there any way to use variables in css?

I would like to write css code like this. Is there any plugin is available for this?

mcolor = #ff00ff;

body
{
    color: mcolor;
}

.ele
{
    width: body.width / 2;
}

Upvotes: 4

Views: 116

Answers (3)

user1972007
user1972007

Reputation: 323

No, Not have any way to use variable in css.

If you want to use varaible then you want to use css in php or javascript or orher language.

For more information. you learn this on

http://lesscss.org/

OR

http://sass-lang.com/

Upvotes: -1

spliter
spliter

Reputation: 12569

In pure CSS it's impossible. But there is a working draft of the spec. It will not be available in the browsers any time soon so in the mean time use LESS or SASS as @Logan Serman suggests

Upvotes: 0

Logan Serman
Logan Serman

Reputation: 29860

Take a look at LESS: http://lesscss.org/ or SASS: http://sass-lang.com/

Upvotes: 6

Related Questions