/    Sign up×
Community /Pin to ProfileBookmark

set variables in css?

Just a question. Is there a way to set varibles in css. For instance…

Say you define some colors:

color1 = #333
color2 = #CCC

And then you could call on them when defining selector properties:

.container{
background-color:color1;
border:1px solid color2;
}

See what I’m going for here? That way you could set your primary colors all in one spot, and then the changes would apply to your entire sheet(s).

So later down the road if you decide you want to change color2 to ‘#999’, it would cascade down changing all the styles you have color2 specified.

Ideas?

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@ray326Jun 08.2006 — .backcolor { background: #333 }

.forecolor { color: #ccc }

Then use those classes in your mark up.

<div class="container backcolor forecolor">
×

Success!

Help @BassMasterFlash spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...