Tuesday, August 4, 2009

ID Selector

* The ID selector works in a similar way to the class selector but with some key differences.
* In the CSS styles area the ID selector is noted with a # before the name (as opposed to the class selector which has a . - for example #header not .header).
* The ID selector should only be used for key components such as the menu system or the footer that only appear once in the document (it can be used more than once but this is bad practise and goes against the W3C Standards).
* Referencing the style in the document is the same as normal, i.e. you place the id="header" attribute inside the tag that you want it to be applied.
* Can also be more specific about where the style is applied by having an element name before the #, for example h1#header: ...
* NB 1: Don't put a space between the h1 and the # - this creates a decendant selector.
* NB 2: The ID tag is case sensitive so be careful when you are naming your ID selectors.

No comments:

Post a Comment