Predict Which Element Gets Styled
Predict Output Easy
Question
Which elements does the selector 'nav a' match?
Code
<nav>
<a href="/">Home</a> <!-- A -->
<ul>
<li><a href="/about">About</a></li> <!-- B -->
</ul>
</nav>
<a href="/help">Help</a> <!-- C -->
Hint
Descendant selectors match any nested element, at any depth.
Explanation
The selector 'nav a' matches any <a> that is a descendant of a <nav> element, at any nesting depth. Elements A and B are both inside <nav> (B is nested deeper but still a descendant). Element C is outside <nav>, so it does not match.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.