Chapter 2. Getting Your Styles to Hit the Target

A valid and well-structured document provides the foundations to which your styles are applied. To be able to style a particular HTML element using CSS, you need to have some way of targeting that element. In CSS the part of a style rule that does this is called the selector.

In this chapter, you will learn about

  • Common selectors

  • Advanced selectors

  • New CSS 3 selectors

  • The wonderful world of specificity and the cascade

  • Planning and maintaining your style sheets

  • How to comment your code

Common selectors

The most common kinds of selectors are type and descendant selectors. Type selectors are used to target a particular type of element, such as a paragraph or a heading element. You do this by simply specifying ...

Get CSS Mastery: Advanced Web Standards Solutions 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.