CHAPTER 6

image

Relationship selectors

Relationship selectors match elements based on their relation with other elements. To understand these selectors, it is important to recognize how elements in a web document are related to each other.

HTML hierarchy

An HTML document can be visualized as a tree with the <html> element as the root. Each element fits somewhere on this tree, and every element is either a parent or a child of another element. Any element above another one is called an ancestor, and the element directly above is the parent. Similarly, an element below another one is called a descendant, and the one directly below is a child. In turn, ...

Get CSS Quick Syntax Reference 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.