- Home
- /
- Tutorials
- /
- CSS Tutorial
- /
- CSS Combinators
CSS Selectors
CSS Combinators
CSS Combinators are used to define relationships between selectors.
They allow you to target elements based on their relationship with other elements in the HTML structure. The supporting concepts are explained in CSS Element Selector and CSS Attribute Selectors.
Using combinators helps create more specific and powerful CSS rules without adding extra classes or IDs.
There are four main CSS combinators:
- Descendant Selector ( )
- Child Selector (>)
- Adjacent Sibling Selector (+)
- General Sibling Selector (~)
Syntax
Descendant Selector
Descendant Selector
css
div p {
color: blue;
}Selects all <p> elements inside a <div>.
