Using pseudo classes

You have already learned how to add classes to elements to apply special styles to them. You are always required to go into the HTML to add the class. Sometimes this can be a problem. For instance, when the content is generated dynamically through a content management system, you may not be able to edit any element because it may not exist in a static HTML file. Enter pseudo classes. Pseudo classes allow you to target elements based on their position in the HTML, and based on other qualities. In this section, we'll look at the first-child pseudo class that can help us style our navigation. We'll then look at several other pseudo classes, for example, last-child and nth-child.

Ultimately, I don't want the home menu, which ...

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.