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 and the .menu elements will receive the font-family: Georgia styling.



Write selectors for the h5 and p elements so they both will be styled with the same CSS rule. Apply this style to both elements:

font-family: Georgia;

Notice that the font across the page will change to Georgia without writing the same CSS rule twice.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?