Selecting Elements by Context

In CSS, you can pinpoint elements depending on their ancestors, their parent, or their siblings (see “Parents and Children” in Chapter 1) (Image through Image).

An ancestor is any element that contains the desired element (the descendant), regardless of the number of generations that separate them.

Image I’ve shortened the text to make the relationships between elements easier to see. Each indentation represents a generation. Note that ...

Get HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.