0
0
CSSmarkup~5 mins

Child selector in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the CSS child selector (>) do?
It selects only the direct children of an element, not deeper nested descendants.
Click to reveal answer
beginner
How would you select all <li> elements that are direct children of a <ul>?
Use the selector ul > li. This targets only li elements directly inside ul, not nested inside other elements.
Click to reveal answer
beginner
True or False: The child selector selects all descendants at any depth.
False. The child selector only selects direct children, not all descendants.
Click to reveal answer
beginner
Example: What elements does div > p select?
It selects all <p> elements that are direct children of a <div> element.
Click to reveal answer
intermediate
Why use the child selector instead of a descendant selector?
To apply styles only to immediate children, avoiding unintended styling of nested elements deeper inside.
Click to reveal answer
Which selector targets only direct children?
Adiv ~ p
Bdiv p
Cdiv + p
Ddiv > p
What does ul > li select?
AOnly <li> that are direct children of <ul>
BAll <li> inside <ul>, at any depth
COnly <ul> elements
DOnly <li> siblings
True or False: div > p selects <p> inside nested <div> inside another <div>.
AFalse
BOnly if nested directly
CTrue
DOnly if <p> is sibling
Which selector would style all paragraphs inside a section, no matter how deep?
Asection > p
Bsection p
Csection + p
Dsection ~ p
Why might you prefer the child selector over the descendant selector?
ATo style all nested elements
BTo select parents
CTo style only immediate children
DTo select siblings
Explain how the CSS child selector works and give an example.
Think about selecting only direct children, not all nested elements.
You got /3 concepts.
    Describe a situation where using the child selector is better than the descendant selector.
    Consider when you want to avoid affecting deeply nested elements.
    You got /3 concepts.