Challenge - 5 Problems
Sass Extend Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What happens when you try to extend a placeholder selector that does not exist?
Consider the following Sass code:
.button { color: blue; @extend %nonexistent; }What will happen when you compile this Sass code?SASS
.button { color: blue; @extend %nonexistent; }
Attempts:
2 left
💡 Hint
Extending a placeholder that is not defined causes a compilation problem.
✗ Incorrect
In Sass, trying to extend a placeholder selector that does not exist causes a compilation error. This prevents silent failures and helps catch mistakes early.
📝 Syntax
intermediate2:00remaining
Which option correctly extends multiple selectors in Sass?
You want to extend both .btn and .link selectors in your Sass code. Which of the following is the correct syntax?
Attempts:
2 left
💡 Hint
Sass supports comma-separated lists in @extend.
✗ Incorrect
In Sass, you can extend multiple selectors at once by separating them with commas inside a single @extend. Separate @extend statements also work.
❓ rendering
advanced2:00remaining
What is the output CSS of this Sass code with nested @extend?
Given this Sass code:
%base { color: red; } .alert { @extend %base; font-weight: bold; } .error { @extend .alert; }What CSS will be generated?SASS
%base { color: red; } .alert { @extend %base; font-weight: bold; } .error { @extend .alert; }Attempts:
2 left
💡 Hint
Extending a selector that itself extends a placeholder merges styles.
✗ Incorrect
The .alert selector extends %base, so it gets color: red. The .error selector extends .alert, so it inherits both color: red and font-weight: bold. Sass merges selectors that share extended styles.
❓ selector
advanced2:00remaining
Why does extending a class with a pseudo-element sometimes fail?
Consider this Sass code:
.btn::before { content: "*"; } .special { @extend .btn::before; }What is the main reason this @extend does not work as expected?SASS
.btn::before { content: "*"; } .special { @extend .btn::before; }
Attempts:
2 left
💡 Hint
Extending pseudo-elements is not supported in Sass.
✗ Incorrect
Sass does not allow extending selectors that include pseudo-elements or pseudo-classes. This is a known limitation because pseudo-elements are not real selectors but parts of selectors.
❓ accessibility
expert3:00remaining
How can improper use of @extend affect accessibility in CSS?
Imagine you use @extend to share styles for focus outlines across buttons and links. What is a potential accessibility risk if @extend merges selectors incorrectly?
Attempts:
2 left
💡 Hint
Merging selectors can cause styles to apply broadly beyond intended targets.
✗ Incorrect
When @extend merges selectors, focus styles intended for buttons might also apply to other elements, causing confusion for keyboard users who rely on clear focus indicators. This can reduce usability and accessibility.