Classifying multiple elements

Classes are also used for classifying multiple elements. If you want to change the h2 tags in the middle section to all be similar but different to h2 tags elsewhere on the page, using a class will be the perfect option. Let's go into our HTML, add a class to all the div tags in the secondary-section, and call it column-title. Go to the The Octopus, The Crab, and The Whale headings, and use Sublime's nice multiple cursor browser feature to add class="column-title" to each one of them. For example, the The Octopus heading should look like this:

<h2 class="column-title">The Octopus</h2> 

Then, we go to our CSS and add .column-title underneath h2. We'll then add some properties and values. Add font-style as normal ...

Get Mastering CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.