0
0
SASSmarkup~20 mins

Null value behavior in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Null Value Mastery in Sass
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does Sass treat null values in property assignments?
Consider the following Sass code snippet:
$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;
}
A
.box {
  background-color: transparent;
  border: 1px solid black;
}
B
.box {
  background-color: ;
  border: 1px solid black;
}
C
.box {
  border: 1px solid black;
}
D
.box {
  background-color: null;
  border: 1px solid black;
}
Attempts:
2 left
💡 Hint
In Sass, null values cause the property to be omitted from the output CSS.
📝 Syntax
intermediate
2:00remaining
What happens when you use null in a Sass list?
Given this Sass code:
$list: 10px null 20px;

.box {
  margin: $list;
}

What is the output CSS margin value?
SASS
$list: 10px null 20px;

.box {
  margin: $list;
}
A
.box {
  margin: 10px 0 20px;
}
B
.box {
  margin: 10px null 20px;
}
C
.box {
  margin: 10px 20px 20px;
}
D
.box {
  margin: 10px 20px;
}
Attempts:
2 left
💡 Hint
Null values in lists are removed when outputting CSS.
rendering
advanced
2:00remaining
What CSS is generated when a null value is used in a nested Sass map?
Consider this Sass code:
$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);
}
A
.box {
  color: null;
  padding: 1rem;
}
B
.box {
  padding: 1rem;
}
C
.box {
  color: ;
  padding: 1rem;
}
D
.box {
  color: transparent;
  padding: 1rem;
}
Attempts:
2 left
💡 Hint
Null values in Sass cause the property to be omitted from the output CSS.
selector
advanced
2: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;
}
A
. {
  color: red;
}
B
.null {
  color: red;
}
C
{
  color: red;
}
DSyntaxError
Attempts:
2 left
💡 Hint
Null interpolated in selectors becomes an empty string.
accessibility
expert
3:00remaining
How does null affect ARIA attribute assignment in Sass?
Given this Sass code:
$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;
}
A
.button {
  background: blue;
}

/* No aria-label attribute output, so no accessibility label */
B
.button {
  aria-label: null;
  background: blue;
}

/* aria-label attribute with 'null' string, confusing screen readers */
C
.button {
  aria-label: '';
  background: blue;
}

/* Empty aria-label, which may cause accessibility issues */
DSyntaxError
Attempts:
2 left
💡 Hint
Null values cause properties to be omitted, so no aria-label CSS property is output.