Constructing Selectors

The selector determines which elements a style rule is applied to. For example, if you want to format all p elements with the Times font, 12 pixels high, you’d need to create a selector that identifies just the p elements while leaving the other elements in your code alone. If you want to format the first p in each section with a special indent, you’ll need to create a slightly more complicated selector that identifies only those p elements that are the first element in their section of the page.

A selector can define up to five different criteria for choosing the elements that should be formatted:

• The type or name of the element .

The simplest kind of selector is simply the name of the type of element that should be ...

Get HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.