Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Or, if you're feeling frisky, an ID and multiple classes  . To place multiple classes on an element, just put a space between them like this:
HTML Code:
<div class="funny news section" id="awesome">
Now, three sets of rules apply to one element. This brings up another interesting point, involving browser compatibility. Wouldn't you know it that all of the browsers see an element with multiple classes in the correct way, except for IE6 and below? IE6 is fine if you state all of the rules separately like this:
CSS
Code:
.funny {
/*rules*/
}
.news {
/*rules*/
}
.section {
/*rules*/
}
but not like this:
CSS
Code:
.funny.news.section {
/*rules*/
}
All of the browsers except for IE6 and below see the above rule as belonging to any element with all three of those classes on it. What IE6 sees, instead, is only the first class .funny. This means that now, instead of obeying the specific nature of the selector, all elements with only the single class, "funny" will have this rule. I almost pulled my hair out the first time this happened to me, I was so mad!
|