Utilizor
Contact Us

CSS Combinators

Learn about CSS combinators and how they define relationships between selectors.

CSS Combinators Reference

A combinator is something that explains the relationship between the selectors.

Combinator Example Description
Descendant Selector (space) div p Selects all <p> elements inside <div> elements
Child Selector (>) div > p Selects all <p> elements that are direct children of a <div> element
Adjacent Sibling Selector (+) div + p Selects the first <p> element that is placed immediately after <div> elements
General Sibling Selector (~) div ~ p Selects all <p> elements that are placed after <div> elements

Example

/* Child Selector */
div > p {
  background-color: yellow;
}