Identifying Selectors

A selector is the element, or group of elements, to which a style will be applied. Selectors can be individual elements, lists of like elements, or specific instances of elements identified by class or ID attributes. In this next section, we'll look at selectors of each type.

Elements as Selectors

Using an element as a selector is pretty straightforward. The style rule is written by giving the element (selector), followed by the property or properties and values bound within braces:

							selector {property:value}

Multiple elements that will have the same properties can be grouped to save redundancy in the style sheet document. For instance, you might want all headings to be colored red. Instead of writing

 h1 {color:red} ...

Get XHTML by Example 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.