O'Reilly logo

Cascading Style Sheets (CSS) by Example by Steve Callihan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Grouping Works

Another key concept in CSS is grouping. Grouping allows the creation of more efficient style sheets, in that selectors can be grouped in order to have the same style properties applied to all the selectors within the group. Similarly, properties can be listed in groups and applied to individual or grouped selectors.

✓ You also already worked with one example of creating a group selector in Chapter 3, “Setting Your Page's Base Styles,” when you applied style properties to both the H1 and H2 elements—see “Using a Group Selector to Set the Other Heading Characteristics,” p. 52 (chapter 3).

In CSS, selectors can be grouped by including them as a comma-separated list. Here's an example of grouping the H1, H2, H3, and H4 element ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required