I'm applying color to different text and I want to know if this is good or bad.
instead of having multiple selectors with commas point to one color which saves a lot of lines of code- example p, .content, #idunno{ color:white}
instead I make a class called color1 and add the class anywhere i want a certain color. i feel this is easier because i can just pull the class off on the html side and its gone. it also helps me keep my color scheme to a minimum and realize when I am using too much variations of the same color.
It really depends on opinion of good practice...I think it is much more flexible personally...a lot of people say not to have classes named after colors etc...but, again, matter of preference, if it is going to make my life easier in the long run, I will do it, in fact, I do it some times...
But how will you remember what "color1" applies to?
It's irrelevant in terms of actual presentation and the output, but thinking long term (as in, "if I come back in 6 months, will I remember this?") and as such you should try and retain colours within their relevant classes.
So the Div class "content" would have "color: #fff" and div class "undercontent" would have the same. That way if you need to change it you know exactly where to look.
It has nothing to do, specifically, with the name you choose (though, as pointed out above, it is a good idea to make understandable class names).
The problem is that you're making a class that only exists to apply one, completely arbitrary, rule - it's no better than writing style="color: red;" in your markup. You're missing the point of CSS and the problems it's intended to solve.
It's also very easy to get carried away, and soon you'll have one CSS class for every possible property:value combination, which is all kinds of "bad things."
Usually, if you want to change text color, there's a reason for it. So if there is some more appropriate concept to build your class around, you should do so:
.error-message{ color: red; /* and then later you might add */ border: 25px dotted purple; }
I wouldn't use classes for colors because of the single use of a class is wasteful to me but it wouldn't hurt your overall sheet via caching or anything as it won't add that much. Depending on the amount of classes.
You can use multiple classes in an element so if you are doing that it could work and may save time.
For example:
<div class="myDiv color1"></div>
In the long run it could save time but whether it is a best practice, not really but when is a consensus ever really 100% correct. :) BUT you are probably wanting to do this to allow a single variable to be added whenever necessary...this can also be done via PHP.
instead of having multiple selectors with commas point to one color which saves a lot of lines of code-
example
p, .content, #idunno{ color:white}
instead I make a class called color1 and add the class anywhere i want a certain color.
i feel this is easier because i can just pull the class off on the html side and its gone.
it also helps me keep my color scheme to a minimum and realize when I am using too much variations of the same color.
the class was called color1
It's irrelevant in terms of actual presentation and the output, but thinking long term (as in, "if I come back in 6 months, will I remember this?") and as such you should try and retain colours within their relevant classes.
So the Div class "content" would have "color: #fff" and div class "undercontent" would have the same. That way if you need to change it you know exactly where to look.
It has nothing to do, specifically, with the name you choose (though, as pointed out above, it is a good idea to make understandable class names).
The problem is that you're making a class that only exists to apply one, completely arbitrary, rule - it's no better than writing
style="color: red;"in your markup. You're missing the point of CSS and the problems it's intended to solve.It's also very easy to get carried away, and soon you'll have one CSS class for every possible property:value combination, which is all kinds of "bad things."
Usually, if you want to change text color, there's a reason for it. So if there is some more appropriate concept to build your class around, you should do so:
You can use multiple classes in an element so if you are doing that it could work and may save time.
For example:
In the long run it could save time but whether it is a best practice, not really but when is a consensus ever really 100% correct. :) BUT you are probably wanting to do this to allow a single variable to be added whenever necessary...this can also be done via PHP.
Chris made an article a couple years back about this...give it a look and see if this helps you with what you are wanting to do. http://css-tricks.com/css-variables-with-php/