Challenge - 5 Problems
Null Value Mastery in Sass
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
How does Sass treat null values in property assignments?
Consider the following Sass code snippet:
What will be the output CSS for the
$color: null;
.box {
background-color: $color;
border: 1px solid black;
}What will be the output CSS for the
.box selector?SASS
$color: null; .box { background-color: $color; border: 1px solid black; }
Attempts:
2 left
💡 Hint
In Sass, null values cause the property to be omitted from the output CSS.
✗ Incorrect
When a Sass variable is null and used as a property value, Sass does not output that property at all. So
background-color: $color; is omitted because $color is null.📝 Syntax
intermediate2:00remaining
What happens when you use null in a Sass list?
Given this Sass code:
What is the output CSS margin value?
$list: 10px null 20px;
.box {
margin: $list;
}What is the output CSS margin value?
SASS
$list: 10px null 20px; .box { margin: $list; }
Attempts:
2 left
💡 Hint
Null values in lists are removed when outputting CSS.
✗ Incorrect
Sass removes null values from lists when outputting CSS. So the margin becomes
10px 20px skipping the null.❓ rendering
advanced2:00remaining
What CSS is generated when a null value is used in a nested Sass map?
Consider this Sass code:
What is the rendered CSS?
$settings: (
color: null,
padding: 1rem
);
.box {
color: map-get($settings, color);
padding: map-get($settings, padding);
}What is the rendered CSS?
SASS
$settings: ( color: null, padding: 1rem ); .box { color: map-get($settings, color); padding: map-get($settings, padding); }
Attempts:
2 left
💡 Hint
Null values in Sass cause the property to be omitted from the output CSS.
✗ Incorrect
Since
color is null, Sass omits the color property entirely. Only padding is output.❓ selector
advanced2:00remaining
How does Sass handle null in selector interpolation?
What is the output CSS of this Sass code?
$name: null;
.#{$name} {
color: red;
}SASS
$name: null; .#{$name} { color: red; }
Attempts:
2 left
💡 Hint
Null interpolated in selectors becomes an empty string.
✗ Incorrect
When null is interpolated in a selector, it becomes an empty string. So the selector is just a dot
. which is invalid CSS but Sass outputs it as is.❓ accessibility
expert3:00remaining
How does null affect ARIA attribute assignment in Sass?
Given this Sass code:
What is the output CSS and what is the accessibility implication?
$aria-label: null;
.button {
aria-label: $aria-label;
background: blue;
}What is the output CSS and what is the accessibility implication?
SASS
$aria-label: null; .button { aria-label: $aria-label; background: blue; }
Attempts:
2 left
💡 Hint
Null values cause properties to be omitted, so no aria-label CSS property is output.
✗ Incorrect
Since $aria-label is null, Sass omits the
aria-label property. This means no CSS attribute is set, so accessibility depends on HTML attributes, not CSS. Setting aria-label in CSS is unusual and may not work as expected.