Challenge - 5 Problems
Interpolation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output CSS of this Sass code using interpolation?
Given the Sass code below, what will be the compiled CSS output?
SASS
$color: red; .button-#{$color} { background-color: $color; }
Attempts:
2 left
💡 Hint
Interpolation replaces #{} with the variable's value inside selectors or property names.
✗ Incorrect
The #{$color} inside the selector is replaced by the value of $color, which is 'red'. The property value uses $color directly, so it compiles to 'red'.
❓ rendering
intermediate2:00remaining
What color will the button have in the browser?
Consider this Sass code. What color will the button have when rendered in the browser?
SASS
$btn-color: blue; .btn-#{$btn-color} { color: $btn-color; }
Attempts:
2 left
💡 Hint
The variable $btn-color is set to blue and used both in selector and property.
✗ Incorrect
The variable $btn-color is blue, so the selector becomes .btn-blue and the color property is blue, so the button text color is blue.
🧠 Conceptual
advanced2:00remaining
Why use #{} interpolation in Sass selectors?
Which reason best explains why #{} interpolation is used in Sass selectors?
Attempts:
2 left
💡 Hint
Think about how variables can change parts of selectors.
✗ Incorrect
Interpolation with #{} allows Sass to replace variables with their values inside selectors or property names, enabling dynamic CSS generation.
❓ selector
advanced2:00remaining
What selector does this Sass code produce?
Given the Sass code below, what is the exact CSS selector generated after compilation?
SASS
$state: active; .menu-item-#{$state} { font-weight: bold; }
Attempts:
2 left
💡 Hint
Interpolation replaces #{$state} with the variable's value.
✗ Incorrect
The variable $state is 'active', so the selector becomes '.menu-item-active'.
❓ accessibility
expert3:00remaining
How can interpolation help with accessible ARIA attributes in Sass?
You want to create multiple buttons with different ARIA labels using Sass variables and interpolation. Which Sass code correctly sets unique ARIA labels using interpolation?
Attempts:
2 left
💡 Hint
Attribute selectors need the variable value as a string inside quotes with interpolation.
✗ Incorrect
Interpolation with #{} inside quotes inserts the variable value correctly in the attribute selector. Option A uses this correctly.