Skip to content
Justice Tech School

Descendant and Child Selectors

A space selects any descendant. > selects only direct children. Use child selectors to avoid styling nested things by accident.

Example
<style>
.menu > li { color: #5eead4 } .menu li li { color: #fbbf24 }
</style>
<ul class="menu"><li>Top<ul><li>Nested</li></ul></li></ul>

Exercise

Direct child symbol.

.menu  li

Quiz Test

What does > select?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.