Forum Moderators: open
The same with the id, the most powerful selector (having a higher specificity than class), though each named id can be used only once per document (page).
One should take care declaring an id and be certain that it will never be needed more than once per document. Most common id usage are for page headers, sidebars, main navigation, and footers. Anything in the middle of the page is more likely to find a situation where you will want to use the id twice - and then you are stuck with needing to hack a class for that declaration before it can be used. id planning is important - as is all site structure.
........................
Example:
#one-time-div {declaration block}
but oops, now (six months later) I want to use this several times on one page.
Fix:
#one-time-div, .fix-the-oops {declaration block}
and you can now use the same declaration for id or class.
You could do
.foo {font-size: 200%;}
.bar {color: green;}
.foo.bar {background-color: orange;}
And then <p class="foo bar">test</p>
would be rendered large, green on orange