A page can use sensible font sizes and still feel uneven: body copy, headings, captions, and labels may have been picked independently or separated by fixed pixel jumps. A modular scale gives those sizes a shared relationship. Starting from one base size, apply the same ratio at every step so the type hierarchy has a deliberate rhythm rather than arbitrary values. section 8.3 section 8.0
The calculation is simple: Sₙ = B × Fⁿ. B is the base size, F is the scaling factor or ratio, and n is the step number. Step 0 is the base; positive steps grow above it and negative steps shrink below it. For a 20px base and a 1.5 ratio, the sequence includes 8.89px, 13.33px, 20px, 30px, 45px, and 67.5px. section 8.3.1 section 8.3.1
Sn = B * Fn
Use the formula to calculate any scale step from a base size, ratio, and step number. section 8.3.1
Choose the ratio for the amount of contrast the hierarchy needs. Ratios up to 1.2 make subtle changes. Ratios from above 1.2 through 1.5 favor readability, while ratios above 1.5 through 1.75 create more dramatic jumps. There is no single correct choice: smaller ratios make neighboring sizes closer, and larger ones make headings more emphatic. section 8.3.2
Table 8.4 Traditional modular scale ratios based on ideas in math and music
| Name |
Ratio |
Example scales (base = |
| Minor third |
1.125 |
|
| Major third |
1.2 |
|
| Perfect fourth |
1.25 |
|
| Augmented fourth |
1.33 |
|
| Square root of two |
1.414 |
|
| Minor sixth |
1.6 |
|
| Golden ratio |
1.618 |
|
| Major sixth |
1.67 |
|
| Octave |
2 |
|
Compare traditional ratios and the size sequences they generate from a 20px base. section 8.3.2
Define a scale once with CSS custom properties
A base of 1.25rem and a 1.618 ratio creates a bold scale. Store both values in custom properties. Divide by the ratio for smaller steps; multiply the previous step for larger ones, because CSS has no exponentiation operator. Assign the resulting variables to headings, paragraphs, and smaller text. Changing --base or --ratio then updates all related sizes together. section 8.3.3 section 8.5
A modular scale organizes font size, not every part of readability by itself. Pair it with suitable line height, line length, and responsive sizing constraints. CSS custom properties and calc() make the scale easier to adjust, while clamp() can constrain fluid type sizes across screen widths. section 8.5
