O'Reilly logo

CSS Mastery: Advanced Web Standards Solutions by Cameron Moll, Simon Collison, Andy Budd

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required