Type Scale & Vertical Rhythm Calculator
Build a modular type scale from a base size and ratio, in px and rem, with every line height snapped to a baseline grid for one shared vertical rhythm.
A table of font sizes and line heights that all sit on the same baseline grid, plus a CSS custom-property block ready to paste into a stylesheet.
Example: 16 px × 1.25 (major third) from −2 to +5 gives 10.24, 12.8, 16, 20, 25, 31.25, 39.06 and 48.83 px; on a 12 px half-line grid the 31.25 px heading takes a 48 px line and the 48.83 px one an 84 px line.
Sizes that multiply,
lines that add up.
How the scale is generated, what the baseline snap does, and where the rem figures come from.
The scale
A modular scale multiplies a base size by a fixed ratio for each step up and divides by it for each step down: size(n) = base × ratioⁿ. The presets are the musical intervals designers commonly reach for (minor third 1.2, major third 1.25, perfect fourth 1.333, augmented fourth 1.414, perfect fifth 1.5, golden 1.618), but any ratio above 1 works. Sizes are shown unrounded in px and as rem at the root size you give (16 px unless you change it), so 20 px is 1.25rem.
Vertical rhythm
Body text at 16 px with line-height 1.5 sits on 24 px lines. For every other size the raw line height (size × line-height) is rounded up to the next multiple of the baseline unit, so a 31.25 px heading takes 48 px rather than 46.875 and the text below it lands back on the grid. The default unit is half the body line (12 px here), the usual compromise between a strict full-line grid and a loose one; type any unit — 4 or 8 px for a spacing-system grid — to override it. The resulting unitless ratio is shown so you can spot steps that end up too tight or too loose and adjust the unit.
The CSS block
The custom properties name each step --step-n in rem with its px size and snapped line height in a comment, plus --baseline for margins that should stay on the grid. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- CSS Values and Units Module Level 4 (W3C) — rem and px units
- CSS Inline Layout Module Level 3 (W3C) — line-height and line box height
Last reviewed 19 September 2026. How results are checked: How we verify.