A B
The descendant combinator: selects elements B that are anywhere inside an element A.
Syntax
A B { … }Examples
Only the links inside .menu are white:
<style>
.menu a { color: white; text-decoration: none; }
.menu { background: slategray; padding: 8px; }
</style>
<nav class="menu"><a href="#">Home</a> <a href="#">Blog</a></nav>
<p><a href="#">A link outside the menu</a></p>Notes
The space means "at any depth": children, grandchildren and further. To select only direct children, use A > B. Long chains like .page .content ul li a are fragile — they break when the markup changes.
See also
In the tutorial
- Selectors — How to pick elements for styling — by tag, class, id, nesting and attribute.