Do CSS classes and IDs always override element selectors?

  • Thread starter Thread starter honestrosewater
  • Start date Start date
  • Tags Tags
    Elements
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
honestrosewater
Gold Member
Messages
2,133
Reaction score
6
Going with the idea that every bit counts, in situations like:
h1, h1.box {
font-size: 1em;
color: #0033cc;
letter-spacing: 0.05em;
}
h1 {margin: 1em;}
h1.box {margin: .2em .5em;}
Can I reduce it to:
h1 {
font-size: 1em;
color: #0033cc;
letter-spacing: 0.05em;
margin: 1em;
}
h1.box {margin: .2em .5em;}
without causing any browser compatibility/bug problems?

In short, will classes and ids *always* win out over nonclasses and non ids, for all elements (div, p, etc.) and settings (position, width, etc.)? Or is there another reason I should despise IE?
Thanks a bushel :biggrin:

Happy thoughts
Rachel
 
Physics news on Phys.org