Challenge - 5 Problems
SASS Stylesheet Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the compiled CSS output?
Given this SASS code, what is the exact CSS output after compilation?
SASS
$primary-color: #3498db; .button { background-color: $primary-color; color: white; padding: 1rem 2rem; border-radius: 0.5rem; }
Attempts:
2 left
💡 Hint
Remember that variables in SASS are replaced with their values during compilation.
✗ Incorrect
SASS variables like $primary-color are replaced with their assigned values (#3498db) in the compiled CSS. The rest of the properties remain unchanged.
❓ layout
intermediate2:00remaining
How does this nested SASS code render in CSS?
What is the compiled CSS output of this nested SASS code?
SASS
.nav { ul { margin: 0; padding: 0; list-style: none; } li { display: inline-block; } a { text-decoration: none; color: #333; } }
Attempts:
2 left
💡 Hint
Nested selectors in SASS compile to combined selectors with parent references.
✗ Incorrect
SASS nesting compiles by prefixing nested selectors with their parent selectors. So ul, li, and a inside .nav become .nav ul, .nav li, and .nav a respectively.
❓ selector
advanced2:00remaining
Which CSS selector is generated by this SASS code?
What is the CSS selector generated by this SASS snippet?
SASS
.card { &-header { font-weight: bold; } &-body { padding: 1rem; } }
Attempts:
2 left
💡 Hint
The & symbol in SASS represents the parent selector.
✗ Incorrect
Using &-header inside .card creates a selector by appending '-header' to '.card', resulting in '.card-header'. Same for &-body producing '.card-body'.
❓ accessibility
advanced2:00remaining
How to improve accessibility with SASS variables?
Which SASS code snippet best supports easy color contrast adjustments for accessibility?
Attempts:
2 left
💡 Hint
Using variables for both text and background colors allows easy updates for contrast.
✗ Incorrect
Defining both text and background colors as variables lets you adjust them together to maintain good contrast, improving accessibility.
🧠 Conceptual
expert3:00remaining
What is the output of this SASS code with mixins and nesting?
Given this SASS code, what is the compiled CSS output?
SASS
@mixin flex-center { display: flex; justify-content: center; align-items: center; } .container { @include flex-center; height: 100vh; .box { width: 10rem; height: 10rem; background: red; } }
Attempts:
2 left
💡 Hint
Mixins insert their CSS properties where included. Nested selectors compile with parent prefixes.
✗ Incorrect
The mixin flex-center adds flexbox properties inside .container. The nested .box becomes .container .box in CSS with its own styles.