1.5. Parts of a CSS Rule

Every style, whether it's embedded in a separate style sheet or not, consists of one or more rules. Figure 1-3 shows a CSS rule with all the parts labeled.

Each rule has exactly two parts:

  • A selector that defines the HTML element(s) to which the rule applies

  • A collection of one or more properties, [2] which describes the appearance of all elements in the document that match the selector

    [2] Many books and articles about CSS call them "attributes," or use the two terms interchangeably. In this book, I used the W3C endorsed terminology of "properties", and reserve the name "attributes" for attributes of HTML tags.

Figure 1-3. Parts of a CSS Rule

Each property consists of a pair of values separated by a colon. The first ...

Get HTML Utopia: Designing Without Tables Using CSS 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.