HTML and CSS Reference
In-Depth Information
only a few statements. Now, what if you want to assign some complex styles to all the
headings in a document, and you want the same styles to be applied to all of them?
Here's how to do it:
h1, h2, h3, h4, h5, h6 {color: gray; background: white; padding: 0.5em;
border: 1px solid black; font-family: Charcoal, sans-serif;}
You've grouped the selectors, so the styles on the right side of the rule will be applied
to all the headings listed; grouping the declarations means that all of the listed styles
will be applied to the selectors on the left side of the rule. The result of this rule is shown
in Figure 1-5 .
Figure 1-5. Grouping both selectors and rules
This approach is preferable to the drawn-out alternative, which would begin with
something like this:
h1 {color: gray;}
h2 {color: gray;}
h3 {color: gray;}
h4 {color: gray;}
h5 {color: gray;}
h6 {color: gray;}
h1 {background: white;}
h2 {background: white;}
h3 {background: white;}
…and continue for many lines. You can write out your styles the long way, but I
wouldn't recommend it—editing them would be as tedious as using font tags every-
Search WWH ::

Custom Search