Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

Nesting selectors

If you want to define a style that only applies if a tag is nested inside another tag (such as bold text inside a paragraph tag), you can use contextual selectors. The CSS2 specification refers to these selectors as descendant selectors.

A contextual or descendant selector is a series of selectors separated by a space, such as:

p b {color: blue;}

In this example, bold text in a paragraph appears in blue. Any other text is unaffected:

This HTML…

Displays as…

<p>A paragraph with a <b>bold</b> word</p>