Modular Type Scale
Developer Tools · Added
Picking heading sizes one at a time produces a set that never quite looks deliberate. A modular scale derives every size from one base and one ratio, so the relationships are consistent by construction — and this writes the result out as CSS custom properties.
1.25 — Major third
Sizes above 64px are shown at 64px in the preview so the page stays readable — the values themselves are unchanged.
The scale
| Step | px | rem | Line height | Typically |
|---|---|---|---|---|
| -2 | 10.24 | 0.64 | 1.6 | Fine print, legal |
| -1 | 12.8 | 0.8 | 1.6 | Small print, captions |
| 0 | 16 | 1 | 1.5 | Body text |
| +1 | 20 | 1.25 | 1.5 | Lead paragraph, h5 |
| +2 | 25 | 1.5625 | 1.35 | h4 |
| +3 | 31.25 | 1.9531 | 1.2 | h3 |
| +4 | 39.063 | 2.4414 | 1.2 | h2 |
| +5 | 48.828 | 3.0518 | 1.1 | h1 |
| +6 | 61.035 | 3.8147 | 1.1 | Display |
CSS
:root {
--text-sm-2: 0.64rem; /* 10.24px — Fine print, legal */
--text-sm-1: 0.8rem; /* 12.8px — Small print, captions */
--text-base: 1rem; /* 16px — Body text */
--text-1: 1.25rem; /* 20px — Lead paragraph, h5 */
--text-2: 1.5625rem; /* 25px — h4 */
--text-3: 1.9531rem; /* 31.25px — h3 */
--text-4: 2.4414rem; /* 39.063px — h2 */
--text-5: 3.0518rem; /* 48.828px — h1 */
--text-6: 3.8147rem; /* 61.035px — Display */
}- The bottom of this scale is 10.2px. Below about 12px text becomes hard to read for many people, and browsers on mobile may enlarge it anyway.
The ratios are musical intervals — a major third is 5:4, a perfect fifth 3:2 — and the point is not that any one is correct but that using a single ratio makes the sizes look chosen rather than arbitrary. Sizes are given in rem as well as px because a rem follows the reader's own browser font-size setting and a px value ignores it, which is an accessibility failure no amount of good proportion fixes. The line heights are a starting point: smaller text needs more leading, and a large heading with the same proportional leading looks loose.
How to use the modular type scale
- 1Set the base size, usually 16px for body text.
- 2Choose a ratio — the musical intervals are named because that is where the idea came from.
- 3Set how many steps you need above and below the base.
- 4Copy the CSS custom properties, or the rem values if you are wiring them in by hand.
Examples
A major third from 16px
- Input
- Base 16px, ratio 1.25, two steps down and five up
- Result
- 10.24, 12.8, 16, 20, 25, 31.25, 39.06, 48.83px — each 25% larger than the one before, with roles and line heights suggested for each.
A tighter scale for dense interfaces
- Input
- Base 16px, ratio 1.125
- Result
- Steps close enough together that a heading and its body text stay in the same visual family — better for dashboards than for editorial pages.
About the modular type scale
Why a ratio beats picking sizes
Choose heading sizes independently and you end up with 32, 24, 20 and 18 — numbers that look reasonable alone and have no relationship to each other. The gaps between them are 8, 4 and 2, so the visual step from H1 to H2 is nothing like the step from H3 to H4, and the hierarchy reads as uneven without it being obvious why.
A ratio fixes the relationship rather than the numbers. Every step is the same proportional jump, so the hierarchy is even at any size and stays even when you change the base. It also removes an argument: the next size is not a matter of taste once the ratio is chosen.
Line height belongs to the scale too
Suggested line heights on this page fall as sizes rise, and that is not a rounding artefact. Long lines of small text need generous leading for the eye to find the start of the next line; a 48px heading spanning two lines needs much less, and inherits an awkward gap if it is given body-text leading.
The usual shape is around 1.5 to 1.6 for body copy, tightening towards 1.1 to 1.2 at display sizes. Setting one line-height for the whole page is the most common way a well-chosen scale still ends up looking wrong.
Frequently asked questions
Which ratio should I pick?
Why are the ratios named after musical intervals?
Should I use the pixel values or the rems?
Do I need every step the scale produces?
Related tools
CSS Clamp Generator
Developer Tools
Build a fluid clamp() that scales a size between two viewport widths.
CSS Unit Converter
Converters
Convert px, rem, em, pt, %, vw and vh against a root font size you set.
CSS Grid Generator
Developer Tools
Build a grid visually — tracks, gaps, alignment and cell spans — and copy the CSS it produces.