CSS child combinator (>)

Definition and Usage

CSS Child Element Combinator (>) is used to select elements that are direct children of a specific parent element.

The element matched by the second selector must be a direct child of the element matched by the first selector.

Note:Elements that are not direct children of the specified parent element will not be selected.

Example

Set the style for each <p> element that is a direct child of the <div> element by selecting and setting it:

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
Support 7.0 Support Support Support

Related Pages

CSS Tutorial:CSS child selector