I am new to html and css and looking for a good place that explains when I should use classes, ID's, Tags, compound identifiers. I just started a web page design using mostly classes for the div's and now I see a lot references to using the ID # for container div's. Is there some place that I can find some general guidelines when to use each type. I am looking to build a website with 50+ pages. Thanks
This is a common source of confusion for CSS newbies.
The golden rule is that IDs can only be used once per page. Classes can be used as often as you like.
IDs have greater specificity in CSS calculations than classes.
So, in the event of a rule clash, IDs always trump classes e.g. #header beats .header
You can use this principle to your advantage in your stylesheets.
e.g. name major page components with an ID such as #col1, #col2, #col3
You can then assign classes to elements within those components and use compound selectors to precisely target specific elements of your page using the column ID (#col1 etc) as the starting point for the 'hook' for the CSS.
e.g.
#col1 p = any paragraph in column 1 only
#col2 ul li = any unordered list item in column 2 only
#col3 .header table tr td = any table cell inside an HTML element where class="header" inside column 3 only
North America
Europe, Middle East and Africa
Asia Pacific