In order to make CSS more concise, it’s possible to add CSS styles to multiple CSS selectors all at once. This prevents writing repetitive code.
For instance, the following code has repetitive style attributes:
h1 { font-family: Georgia; } .menu { font-family: Georgia; }
Instead of writing font-family: Georgia
twice for two selectors, we can separate the selectors by a comma to apply the same style to both, like this:
h1, .menu { font-family: Georgia; }
By separating the CSS selectors with a comma, both the <h1>
elements and the elements with the menu
class will receive the font-family: Georgia
styling.
Instructions
In style.css, write selectors for the <h5>
and <li>
elements so they will both be styled with the same CSS rule. Apply this style declaration:
font-family: monospace;
Notice that both the <h5>
and <li>
element’s fonts will change, without writing the same CSS declaration twice.