0
0
SASSmarkup~20 mins

Typography scale generation in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Typography Scale Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the base font size in a typography scale
In a Sass typography scale, what role does the base font size variable usually play?
AIt controls the line height for all text elements.
BIt sets the starting font size from which all other sizes scale proportionally.
CIt specifies the font family used throughout the site.
DIt defines the maximum font size allowed in the scale.
Attempts:
2 left
💡 Hint
Think about what 'base' means in scaling something up or down.
📝 Syntax
intermediate
2:00remaining
Correct Sass syntax for a modular scale function
Which Sass function correctly calculates a modular scale font size given a step and a ratio?
SASS
@function modular-scale($step, $base: 1rem, $ratio: 1.25) {
  @return $base * math.pow($ratio, $step);
}
A
@function modular-scale($step, $base: 1rem, $ratio: 1.25) {
  @return $base * math.pow($ratio, $step);
}
B
@function modular-scale($step, $base: 1rem, $ratio: 1.25) {
  @return $base * $ratio ^ $step;
}
C
@function modular-scale($step, $base: 1rem, $ratio: 1.25) {
  @return $base * ($ratio ** $step);
}
D
@function modular-scale($step, $base: 1rem, $ratio: 1.25) {
  @return $base * pow($ratio, $step);
}
Attempts:
2 left
💡 Hint
Sass math functions require the math module and use math.pow for exponentiation.
rendering
advanced
2:00remaining
Visual output of a typography scale with negative steps
Given this Sass code snippet, what font size will be applied to the class .small-text? @use 'sass:math'; $base-size: 1rem; $ratio: 1.2; @function modular-scale($step) { @return $base-size * math.pow($ratio, $step); } .small-text { font-size: modular-scale(-2); }
A1.2 rem
B0.833 rem
C0.694 rem
D1.44 rem
Attempts:
2 left
💡 Hint
Calculate 1rem * (1.2 ^ -2).
selector
advanced
2:00remaining
Selecting headings with a typography scale in Sass
Which Sass selector correctly applies different modular scale font sizes to all heading levels h1 through h6 using a loop?
SASS
@use 'sass:math';
$base-size: 1rem;
$ratio: 1.25;
@function modular-scale($step) {
  @return $base-size * math.pow($ratio, $step);
}
A
@for $i from 1 through 6 {
  h#{$i} {
    font-size: modular-scale($i);
  }
}
B
@each $i in 1 2 3 4 5 6 {
  h#{$i} {
    font-size: modular-scale($i);
  }
}
C
@each $i in 1 2 3 4 5 6 {
  h#{$i} {
    font-size: modular-scale(6 - $i);
  }
}
D
@for $i from 1 through 6 {
  h#{$i} {
    font-size: modular-scale(6 - $i);
  }
}
Attempts:
2 left
💡 Hint
Heading 1 is usually the largest, so it should have the highest step.
accessibility
expert
2:30remaining
Ensuring accessible typography scale with Sass
Which Sass approach best supports accessibility by maintaining readable font sizes across devices when using a modular scale?
AUse relative units like rem for base size and apply modular scale with media queries adjusting the base size.
BUse fixed pixel sizes for all font sizes to keep consistency.
CApply modular scale only once without adjusting for different screen sizes.
DUse em units for base size and avoid media queries to keep font sizes static.
Attempts:
2 left
💡 Hint
Think about how users zoom or change device sizes and how font sizes should adapt.