0
0
CSSmarkup~5 mins

Descendant selector in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a descendant selector in CSS?
A descendant selector targets elements that are inside another element, no matter how deep. It uses a space between selectors to show this relationship.
Click to reveal answer
beginner
How do you write a descendant selector to style all span elements inside a div?
You write it as div span { /* styles here */ }. This means any span inside a div will get the styles.
Click to reveal answer
beginner
True or False: The descendant selector only selects direct children elements.
False. The descendant selector selects all elements inside another element, at any level, not just direct children.
Click to reveal answer
beginner
Example: What elements does this selector target? article p
It targets all p elements that are inside an article element, no matter how deeply nested.
Click to reveal answer
intermediate
Why use descendant selectors instead of just class or id selectors?
Descendant selectors help style elements based on their location inside other elements. This keeps CSS organized and avoids adding many classes or ids.
Click to reveal answer
Which CSS selector targets all li elements inside a ul?
Aul > li
Bul + li
Cli ul
Dul li
What does the space between selectors mean in CSS?
AAdjacent sibling
BDirect child only
CDescendant relationship
DNo relation
Which selector matches only direct children?
Adiv span
Bdiv > span
Cdiv + span
Ddiv ~ span
If you want to style all paragraphs inside a section, which selector is correct?
Asection p
Bp section
Csection > p
Dsection + p
True or False: Descendant selectors can select elements nested multiple levels deep.
ATrue
BFalse
COnly one level deep
DOnly siblings
Explain what a descendant selector is and how it works in CSS.
Think about how you find something inside a box inside a bigger box.
You got /3 concepts.
    Describe the difference between a descendant selector and a child selector in CSS.
    One is like any family member inside a house, the other is only the children living directly in the house.
    You got /3 concepts.