ID selectors

ID selectors are similar to class selectors. They can be used to select any HTML element that has an ID attribute, regardless of their position in the document tree. Examples of ID selectors:

#navigation { width: 12em; color: #333; }
div#navigation { width: 12em; color: #333; }

The major difference is that IDs can only be applied once per page, while classes can be used as many times on a page as needed.

ID selectors are well supported across standards-compliant browsers.

Further information

Descendant selectors »

Other Max Design articles and presentations
Associated with