Shining Arcanine wrote:You are supposed to use IDs for unique content (e.g. content that is positioned) and classes for general content (e.g. style and formatting). Doing ".special {top:0}" might work in some browsers, but it is wrong. Also, doing #somediv.special is perfectly acceptable. You could even do some "#somediv p.special class" or something even more specific. I think that this is explained in the CSS specification. I suggest that you read it. It is probably the best source for information on CSS.
Not the type of response I was expecting, but thanks. As you said:
ID is a unique element in the page - there can be only one. If the same ID is specified more than once, most likely the styles will be applied to the first instance only.
Class is a set of elements - the same class can be applied to multiple elements on the same page.
That's all well and good.
The issue, though, is precedence. ID takes precedence over class, so this problem arises: what if I want to override the styling of a particular ID on a couple of pages and do it in the most efficient way possible? To override the style of the ID, I could use an in-line style, or, I could use a style in the <head>, but both of those approaches require editing every page. #myID.myClass is the perfect solution and the simplest too - no javascript or anything like that required. #myID.myClass is more specific than #myID, and so it takes precedence.
What I find interesting and the point that I was making is that the ability to use the declaration syntax #myID.myClass is not mentioned on any tutorial site that I have come across and even several Google searches didn't turn up anything specifically applicable to that. I'm pretty certain it is just a matter of the specific search term I used, but there are only so many search terms that come to mind, so whatever terminology is used to describe this ability in the W3C CSS specifications must be just as obscure as the ability itself