0
0
SASSmarkup~20 mins

Extend limitations and gotchas in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Extend Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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; }
AThe compiler creates an empty selector for %nonexistent and applies styles to .button.
BThe compiler ignores the @extend and compiles the .button class normally.
CThe compiler throws an error because the placeholder %nonexistent does not exist.
DThe compiler duplicates the .button styles without any warning or error.
Attempts:
2 left
💡 Hint
Extending a placeholder that is not defined causes a compilation problem.
📝 Syntax
intermediate
2: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?
A@extend .btn; @extend .link;
B@extend .btn, .link;
C@extend (.btn, .link);
D@extend .btn .link;
Attempts:
2 left
💡 Hint
Sass supports comma-separated lists in @extend.
rendering
advanced
2: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; }
A.alert, .error { color: red; font-weight: bold; }
B.alert { color: red; font-weight: bold; } .error { font-weight: bold; }
C.alert { color: red; font-weight: bold; } .error { color: red; }
D.alert, .error { color: red; } .alert { font-weight: bold; }
Attempts:
2 left
💡 Hint
Extending a selector that itself extends a placeholder merges styles.
selector
advanced
2: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; }
AThe .special class must be nested inside .btn to extend its pseudo-element.
BPseudo-elements cannot have content property in Sass.
CThe syntax for extending pseudo-elements requires escaping the colons.
DSass does not support extending selectors with pseudo-elements like ::before.
Attempts:
2 left
💡 Hint
Extending pseudo-elements is not supported in Sass.
accessibility
expert
3: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?
AFocus styles might be applied to unintended elements, confusing keyboard users.
BThe CSS file size will increase, slowing down page load and hurting accessibility.
CScreen readers will ignore elements with extended styles, reducing accessibility.
D@extend automatically disables focus outlines, making keyboard navigation impossible.
Attempts:
2 left
💡 Hint
Merging selectors can cause styles to apply broadly beyond intended targets.