0
0
SASSmarkup~20 mins

Spacing scale generation in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spacing Scale Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output CSS of this Sass spacing scale?
Given the Sass code below, what is the generated CSS for the .spacing-3 class?

$spacing-scale: (0, 0.25rem, 0.5rem, 1rem, 2rem);
.spacing-3 {
  margin: nth($spacing-scale, 4);
}
SASS
$spacing-scale: (0, 0.25rem, 0.5rem, 1rem, 2rem);
.spacing-3 {
  margin: nth($spacing-scale, 4);
}
A.spacing-3 { margin: 1rem; }
B.spacing-3 { margin: 0.5rem; }
C.spacing-3 { margin: 2rem; }
D.spacing-3 { margin: 0.25rem; }
Attempts:
2 left
💡 Hint
Remember that nth() starts counting from 1 in Sass lists.
🧠 Conceptual
intermediate
2:00remaining
How does Sass map spacing scale keys to values?
Consider this Sass map:
$spacing-map: (
  small: 0.5rem,
  medium: 1rem,
  large: 2rem
);

Which Sass function correctly retrieves the value for medium?
Aget($spacing-map, 'medium')
Bmap-get($spacing-map, medium)
Cmap-get($spacing-map, 'medium')
Dnth($spacing-map, 2)
Attempts:
2 left
💡 Hint
Map keys are strings or identifiers and need quotes if strings.
selector
advanced
2:00remaining
Which selector applies spacing scale with Sass @each loop?
Given this Sass code:
$spacing-scale: (0, 0.25rem, 0.5rem, 1rem);

@each $space in $spacing-scale {
  .m-#{$space} {
    margin: $space;
  }
}

What is the correct CSS output for the class .m-0.5rem?
A.m-05rem { margin: 0.5rem; }
B.m-0.5rem { margin: 0.5rem; }
C.m-0\.5rem { margin: 0.5rem; }
D.m-0_5rem { margin: 0.5rem; }
Attempts:
2 left
💡 Hint
CSS class names cannot contain unescaped dots.
layout
advanced
2:00remaining
How to create a responsive spacing scale with Sass and CSS variables?
Which Sass snippet correctly generates CSS variables for spacing scale that change at a breakpoint?

$spacing-scale: (0: 0, 1: 0.5rem, 2: 1rem);

:root {
  @each $key, $value in $spacing-scale {
    --space-#{$key}: #{$value};
  }
}

@media (min-width: 40rem) {
  :root {
    --space-1: 1rem;
    --space-2: 2rem;
  }
}
AGenerates invalid CSS variables due to wrong syntax
BGenerates fixed spacing variables without media query effect
CGenerates spacing variables but media query overrides are ignored
DGenerates CSS variables for spacing that update at 40rem breakpoint
Attempts:
2 left
💡 Hint
CSS variables can be redefined inside media queries for responsiveness.
accessibility
expert
2:00remaining
How to ensure spacing scale changes do not break accessibility?
When generating spacing scales in Sass for margins and paddings, which practice best supports accessibility and user preferences?
AUse CSS variables with rem units and allow user zoom and font scaling
BHardcode spacing values in pixels inside media queries
CUse px units for precise control over spacing
DUse fixed rem values only, ignoring user browser settings
Attempts:
2 left
💡 Hint
Accessibility benefits from scalable units and respecting user settings.