O'Reilly logo

HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition by Bruce Hyslop, Elizabeth Castro

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

Combining Selectors

The examples throughout the chapter have been simple to help you get a feel for various selector types. However, the real power lies in the fact that you can combine any of the techniques in order to pinpoint the elements that you’re interested in formatting.

A bit of an extreme example is shown in Image to demonstrate what’s possible. Here are a few ways you could achieve the same results, moving from least specific to most specific:

em {    color: red;}.project em {    color: red;}.about .project em {    color: red;}#gaudi em {    color: red;}

Here’s a doozy for you. Moving right to left, it says “choose only the em elements that ...

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