CSS3 Selectors: Groups of selectors

This entry is part 3 of 40 in the series CSS3 Selectors

A comma-separated list of selectors represents the union of all elements selected by each of the individual selectors in the list.

In this example, we condense three rules with identical declarations into one. Thus,

h1 { font-family: sans-serif }
h2 { font-family: sans-serif }
h3 { font-family: sans-serif }

is equivalent to:

h1, h2, h3 { font-family: sans-serif }
<!DOCTYPE html>
<head lang="en">
    <meta charset="UTF-8">
        h1, h2, h3 { font-family: sans-serif }
<h1>Country Music</h1>
<h2>Taylor Swift</h2>
<h3>Hot Country Girl</h3>

<p> Taylor Swift moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music.</p>
Series Navigation<< CSS3 Selectors: Type selector
CSS3 Selectors: Universal selector * >>