What are child selectors in CSS?
The child selector uses the > sign and selects only the direct children of an element. The descendant selector (a space) selects children at any depth.
div > p { color: green; } /* only p directly inside div */
div p { color: red; } /* every p inside div, at any depth */
<div>
<p>Direct child</p>
<section>
<p>Not a direct child</p>
</section>
</div>
Here div > p matches only the first paragraph. See CSS Selectors.
Learn more about the similar topics:
| Tutorials |
|---|
| CSS Selectors |
| CSS Specificity |
| CSS Pseudo-classes and Pseudo-elements |
| Exercises & Assignments |
|---|
| No Content Found. |