3.4. Selectors and Structure of CSS Rules

Recall from Chapter 1, that every CSS style rule consists of two parts: a selector, which defines the type(s) of HTML element(s) to which the style rule applies, and a series of property declarations that define the style.

So far, we've seen only simplistic selectors. Typically, they've contained only one element:

h1 {
  font-size: 18px;
  text-transform: capitalize;
}

We have encountered one or two instances where a single rule is designed to apply to more than one kind of HTML element:

h1, h2, h3 {
  font-size: 18px;
  text-transform: capitalize;
}

These are the most basic selectors in CSS. There are many others. Table 3-1 summarizes all the selector types available in CSS, roughly from simplest to most ...

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.