I have a general rule which gives all DIVs a background image.
I have one div (with id='a') which I don't want it to have the background image.
What css rule do I have to give it?
views:
508answers:
5
A:
Doesn't this work:
.clear-background{ background-image: none; }
Might have problems on older browsers....
Ben Hall
2009-09-22 16:18:15
+2
A:
div#a {
background-image: none !important;
}
Although the "!important" might not be necessary, because "div#a" has a higher specificity than just "div".
M4N
2009-09-22 16:18:23
The !important part is not necessary as the declaration with #a is more precise than a declaration of div and therefore this rule will be applied instead of the general div rule.
Ruud v A
2009-09-22 16:20:31
+1
A:
If your div rule is just div {...}
, then #a {...}
will be sufficient. If it is more complicated, you need a "more specific" selector, as defined by the CSS specification on specificity. (#a being more specific than div is just single aspect in the algorithm.)
Justin Love
2009-09-22 16:30:19