What is CSS immediate child?
The CSS child combinator (>) can be used to select all elements that are the immediate children of a specified element.
A combinator combines and explains the relationship between two or more selectors.
Syntax
selector1 > selector2 { style properties }
It matches only those elements matched by the second selector (selector2) that are the direct children of elements matched by the first selector (selector1).
Code
In this example, add a background-color property to all the immediate child (p) elements of the parent (div) element.
Notice that the CSS property does not apply to the third
pelement as it is not an immediate child.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved