-1

Im working on a website and my boss wants me to use CSS variations and I dont know what he is talking about.

Let's say I have 20 different elements using #7d2d39, rather than having:

background-color:#7d2d39
color="#7d2d39"

All over the style sheets he wants me to call it using:

background-color:red1"
color="red1"

and somewhere define what "red1" is that way we can globally change one hex color vs. changing it 20 times? It makes sense as I type it, but I dont think this exists.

1
  • 4
    I know this is very radical and maybe totally crazy... How about asking your boss to explain what he means? :) Commented Dec 19, 2012 at 22:09

3 Answers 3

3

You'd need to use something like LESS which supports dynamic stylesheets and variables.

Sign up to request clarification or add additional context in comments.

1 Comment

You forgot to mention the other popular CSS preprocessors: Sass and Stylus.
2

CSS preprocessors are a way of making CSS more "programmatic" by using things like functions and variables. The two most popular are:

And then there's others:

And there's projects like Twitter Bootstrap which uses LESS. There's nothing directly usable in CSS at this moment. It all requires either a JavaScript or a backend processing to convert the LESS/SASS file into CSS.

But it can help developer keep code organized and cleaned and make managing updates faster.

I've never heard of the term "CSS Variants" before but I would suspect your boss might have meant "CSS Variables", which is more what you're describing. But variables are only a part of the functionality preprocessors offer.

I hope that helps!

Comments

2

I think he is talking about css variables but this is just a draft. LESS and SASS are options, too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.