Challenge - 5 Problems
Sass Parent Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
What CSS selector does this Sass code produce?
Given the Sass code below, what is the resulting CSS selector for the nested rule?
SASS
.button { &-primary { color: blue; } }
Attempts:
2 left
💡 Hint
The & symbol represents the parent selector exactly as it is.
✗ Incorrect
The & in Sass replaces itself with the parent selector. Here, &-primary becomes .button-primary.
❓ selector
intermediate2:00remaining
Which CSS selector is generated by this Sass snippet?
Look at this Sass code and choose the correct CSS selector it compiles to:
SASS
.nav { ul { &.active { font-weight: bold; } } }
Attempts:
2 left
💡 Hint
The & replaces the parent selector exactly where it appears.
✗ Incorrect
The & in &.active replaces the parent selector ul, so it becomes ul.active inside .nav.
📝 Syntax
advanced2:00remaining
What error does this Sass code cause?
Examine this Sass code and select the error it produces when compiled:
SASS
.card { &__header { color: red } }
Attempts:
2 left
💡 Hint
Check punctuation carefully in CSS properties.
✗ Incorrect
The property 'color: red' is missing a semicolon at the end, causing a syntax error.
❓ rendering
advanced2:00remaining
What visual style will the button have?
Given this Sass code, what color will the button text be in the browser?
SASS
.btn { color: black; &--danger { color: red; } }
Attempts:
2 left
💡 Hint
Look at how the nested selector changes the class name and color.
✗ Incorrect
The nested selector &--danger becomes .btn--danger, which sets color to red, overriding the base .btn color.
❓ accessibility
expert3:00remaining
How does using & in Sass help maintain accessibility in CSS?
Choose the best explanation of how the parent selector & can improve accessibility in CSS code:
Attempts:
2 left
💡 Hint
Think about how naming conventions affect accessibility tools.
✗ Incorrect
Using & helps create consistent class names, which can be referenced in ARIA labels or scripts, aiding screen readers and accessibility.