Challenge - 5 Problems
Child Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
Which CSS rule applies only to direct children?
Given the HTML structure:
Which CSS selector will style only the <p> inside the <div> but not the <p> inside the <section>?
<div>
<p>Paragraph 1</p>
<section>
<p>Paragraph 2</p>
</section>
</div>Which CSS selector will style only the <p> inside the <div> but not the <p> inside the <section>?
Attempts:
2 left
💡 Hint
The child selector uses a special symbol between parent and child.
✗ Incorrect
The '>' symbol in CSS means direct child. So 'div > p' styles only paragraphs that are immediate children of the div, not deeper nested ones.
🧠 Conceptual
intermediate1:30remaining
What does the child selector target?
In CSS, what does the child selector (>) select?
Attempts:
2 left
💡 Hint
Think about the difference between '>' and a space in selectors.
✗ Incorrect
The child selector '>' targets only elements that are direct children of a parent, not grandchildren or deeper descendants.
📝 Syntax
advanced1:30remaining
Identify the syntax error in this child selector
What error does this CSS code cause?
div > > p { color: blue; }CSS
div > > p { color: blue; }Attempts:
2 left
💡 Hint
Check the number of '>' symbols in the selector.
✗ Incorrect
The child selector uses a single '>' between parent and child. Double '>' is invalid syntax in CSS.
❓ rendering
advanced2:00remaining
What color will the text be?
Given this HTML:
And this CSS:
Which list items will appear green?
<ul>
<li>Item 1</li>
<li>
Item 2
<ul>
<li>Subitem 1</li>
</ul>
</li>
</ul>And this CSS:
ul > li { color: green; }Which list items will appear green?
CSS
ul > li { color: green; }Attempts:
2 left
💡 Hint
Remember the child selector targets immediate children only.
✗ Incorrect
'Item 1' and 'Item 2' are direct children of the first ul, so they get green. 'Subitem 1' is a child of a nested ul, so it is not selected.
❓ accessibility
expert2:30remaining
Why use child selectors for accessibility styling?
When styling a navigation menu with nested lists, why is it important to use the child selector (>) instead of a descendant selector (space) for focus styles?
Attempts:
2 left
💡 Hint
Think about how users navigate nested menus and what styles they expect.
✗ Incorrect
Using the child selector limits focus styles to top-level items, helping screen reader and keyboard users understand the menu structure clearly without confusing nested items.