0
0
SASSmarkup~20 mins

Default values with !default in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Default Values Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does the !default flag do in Sass?
In Sass, what is the purpose of using the !default flag when assigning a variable?
AIt assigns the variable only if it hasn't been assigned a value before.
BIt forces the variable to be reassigned even if it already has a value.
CIt makes the variable global regardless of where it is declared.
DIt marks the variable as read-only and prevents changes.
Attempts:
2 left
💡 Hint
Think about how Sass handles variables that might already have values.
📝 Syntax
intermediate
2:00remaining
What is the output CSS of this Sass code with !default?
Given the Sass code below, what CSS will be generated?
SASS
$color: blue !default;
$color: red;

body {
  color: $color;
}
Abody { color: blue red; }
Bbody { color: red; }
Cbody { color: blue; }
DSyntax error due to multiple assignments
Attempts:
2 left
💡 Hint
Remember the order of variable assignments and how !default works.
selector
advanced
2:00remaining
Which Sass variable assignment will NOT override a previous value?
Assuming $font-size is already set to 16px, which assignment will keep the original value?
A$font-size: 18px !global;
B$font-size: 18px;
C$font-size: 18px !default;
D$font-size: 18px !important;
Attempts:
2 left
💡 Hint
Think about how !default behaves compared to normal assignment.
layout
advanced
2:00remaining
How does !default help in theming Sass files?
You want to create a theme system where users can override colors before importing your styles. How does using !default in your variables help achieve this?
AIt allows users to set variables before import, and your defaults only apply if they haven't set them.
BIt forces users to import your variables first, then override them after.
CIt disables variable overrides completely to keep your theme consistent.
DIt automatically merges user variables with your defaults at runtime.
Attempts:
2 left
💡 Hint
Think about the order of Sass imports and variable assignments.
accessibility
expert
3:00remaining
Why is using !default important for accessible and maintainable Sass code?
Consider a large project with multiple Sass files and contributors. How does using !default for variables improve accessibility and maintainability?
AIt disables variable usage in nested selectors to avoid confusion.
BIt forces all variables to be declared in a single file, improving accessibility.
CIt automatically generates ARIA attributes for components.
DIt prevents accidental overwrites of variables, allowing consistent styling and easier updates.
Attempts:
2 left
💡 Hint
Think about how consistent variable values help keep styles predictable and easy to change.