CSS Adjacent Sibling Combinator (+)

Definition and Usage

CSS Adjacent Sibling Combinator (+) is used to select elements that immediately follow another specific element.

Example

Select and set the style of the <p> element that immediately follows the <div> element (not inside):

div + p {
  background-color: gold;
  border: 1px solid gray;
}

Try It Yourself

CSS Syntax

element1 + element2 {
  css declarations;
}

Technical Details

Version: CSS2

Browser Support

The numbers in the table indicate the first browser version that fully supports the combination.

Chrome Edge Firefox Safari Opera
Soporte 7.0 Soporte Soporte Soporte

Páginas relacionadas

Tutorial de CSS:Selector de hermano adyacente de CSS