Challenge - 5 Problems
Nesting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
What is the output CSS selector?
Given this Sass code, what is the compiled CSS selector for the
.button hover state?SASS
$color: blue; .button { color: $color; &:hover { color: darken($color, 10%); } }
Attempts:
2 left
💡 Hint
Remember that
&:hover appends :hover to the parent selector.✗ Incorrect
The
& symbol in Sass refers to the parent selector. So &:hover becomes .button:hover. The darken function darkens the color blue by 10%, resulting in #00008b.❓ layout
intermediate2:00remaining
How many CSS rules are generated?
Consider this Sass code avoiding over-nesting. How many CSS rules will be generated?
SASS
.nav { display: flex; .item { padding: 1rem; } &.active { background: green; } }
Attempts:
2 left
💡 Hint
Count each unique selector generated after nesting.
✗ Incorrect
The Sass code generates three CSS rules:
.nav { display: flex; }, .nav .item { padding: 1rem; }, and .nav.active { background: green; }.🧠 Conceptual
advanced2:00remaining
Why avoid deep nesting in Sass?
What is the main reason to avoid deep nesting in Sass stylesheets?
Attempts:
2 left
💡 Hint
Think about how CSS specificity affects styling and maintenance.
✗ Incorrect
Deep nesting creates very specific selectors that are hard to override later. This makes the CSS harder to maintain and can cause unexpected styling issues.
📝 Syntax
advanced2:00remaining
Which Sass code avoids over-nesting?
Choose the Sass code snippet that avoids over-nesting while styling a card component with a title and description.
Attempts:
2 left
💡 Hint
Avoid nesting selectors inside each other more than one level deep.
✗ Incorrect
Option B nests only one level deep inside
.card. Both .title and .description are siblings, which avoids over-nesting and keeps CSS simpler.❓ accessibility
expert3:00remaining
How does over-nesting affect accessibility?
Which statement best explains how over-nesting in Sass can indirectly impact web accessibility?
Attempts:
2 left
💡 Hint
Think about how CSS specificity affects style overrides for accessibility features.
✗ Incorrect
When selectors are too specific due to over-nesting, it becomes difficult to override styles like focus outlines. This can reduce keyboard navigation clarity, which is important for accessibility.