views:

508

answers:

5

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?

+5  A: 
div#a {
    background-image: none;
}
Ruud v A
+6  A: 

Try:-

div#a {background-image:none}
AnthonyWJones
A: 

Doesn't this work:

.clear-background{ background-image: none; }

Might have problems on older browsers....

Ben Hall
+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
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
+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