Specifying Groups of Elements

It’s often necessary to apply the same style rules to more than one element. You can either reiterate the rules for each element, or you can combine selectors and apply the rules in one fell swoop.

Figure 9.38. There is one h1 and two h2 elements.

To apply styles to groups of elements:

1.
Type selector1, where selector1 is the name of the first element that should be affected by the style rule.
2.
Type , (a comma).
3.
Type selector2, where selector2 is the next tag that should be affected by the style rule.
4.
Repeat steps 2–3 for each additional element.

✓ Tips

  • This is nothing more than a handy shortcut. The ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide 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.