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

Adjacent selectors

The adjacent selector is represented by a plus (+) sign. This allows you to apply a style to a tag that immediately follows another tag. For example:

h1 + p {color: blue;}

This example means that any time a <p> is the first tag after an <h1> tag, the paragraph is in blue. Other paragraphs are normal.

You can combine this selector with other types of selector. For example:

h1.first + p {color: blue;}

This example means that that any time a paragraph is the first tag after an <h1> tag with the class first, the paragraph is in blue. Other paragraphs are normal.