When writing CSS rules, it’s possible to require an HTML element to have two or more CSS selectors at the same time.

This is done by combining multiple selectors, which we will refer to as chaining. For instance, if there was a special class for <h1> elements, the CSS would look like below:

h1.special { }

The code above would select only the <h1> elements with a class of special. If a <p> element also had a class of special, the rule in the example would not style the paragraph.



Let’s use chaining to select only the <h2> elements with destinations, and add a style to them.

In style.css, write a CSS selector for <h2> elements with a class of .destination. Inside the selector’s curly braces, add this declaration:

font-family: Tahoma;

This will change the font of the h2 elements that also have the class destination. The last <h2> element (“More Destinations”) will remain unchanged.

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?