Class and ID Selectors

So far, all of the selectors we’ve seen have been tied to specific elements. Class selectors and ID selectors give you the opportunity to target elements that you’ve named yourself, independent of the document element.

Elements are named using the class and id attributes. They can be applied to all XHTML elements except base, head, html, meta, script, style, and title. In addition, class may not be used in basefont and param. Class and ID selectors work in slightly different ways.

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.