0
0
CSSmarkup~20 mins

Descendant selector in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Descendant Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
What elements does the descendant selector target?
Given the CSS selector div p, which elements will be styled?
AAll <code>p</code> elements that are inside any <code>div</code>, no matter how deeply nested.
BOnly <code>div</code> elements that are siblings of <code>p</code> elements.
CAll <code>div</code> elements that contain a <code>p</code> element.
DOnly <code>p</code> elements that are direct children of a <code>div</code>.
Attempts:
2 left
💡 Hint
Think about how spaces in selectors work in CSS.
📝 Syntax
intermediate
2:00remaining
Identify the valid descendant selector syntax
Which of the following CSS selectors correctly uses the descendant selector to style all span elements inside section elements?
Asection span
Bsection + span
Csection > span
Dsection, span
Attempts:
2 left
💡 Hint
The descendant selector uses a space between selectors.
rendering
advanced
2:00remaining
What color will the text inside the nested p be?
Given this HTML and CSS, what color will the text inside the nested p be?

<div><section><p>Hello</p></section></div>

div p { color: blue; }
section p { color: red; }
ABlue
BBlack (default)
CRed
DPurple
Attempts:
2 left
💡 Hint
Specificities are equal; consider the order of the rules.
accessibility
advanced
2:00remaining
How does the descendant selector affect accessibility when styling nested elements?
If you use a descendant selector like nav a to style links inside a navigation, what should you consider for accessibility?
AYou must add ARIA roles to all elements matched by descendant selectors.
BDescendant selectors automatically improve keyboard navigation.
CDescendant selectors disable screen readers for nested elements.
DEnsure the color contrast of the styled links meets accessibility standards.
Attempts:
2 left
💡 Hint
Think about visual clarity and readability.
🧠 Conceptual
expert
2:00remaining
Why might descendant selectors cause performance issues in large documents?
Consider a CSS rule like body div ul li a. Why can this descendant selector be less efficient for browsers to apply?
ABecause descendant selectors always cause syntax errors in large documents.
BBecause the browser must check each <code>a</code> element and verify the entire ancestor chain matches, which is slower for deep selectors.
CBecause browsers ignore descendant selectors with more than three levels.
DBecause descendant selectors prevent caching of styles.
Attempts:
2 left
💡 Hint
Think about how browsers match selectors from right to left.