What vertical rhythm is
Vertical rhythm is the principle that every line of text on a page should sit on a regularly spaced horizontal grid, like ruled notebook paper. When body text has a line-height of 24 pixels, every heading, list item, and paragraph margin should be a multiple of 24 pixels too. The result is a visual cadence where columns of text line up across a page, even when they contain different typographic sizes.
Print designers have done this for centuries. The web inherited the practice unevenly. Most modern sites have a rhythm that drifts: a heading might be set to 1.5em line-height, paragraphs might be 1.6, margins might be 0.75em, and nothing aligns. The Calculator here keeps the math honest by computing every value as a multiple of one base unit, and can measure each element's baseline in your browser and nudge it onto the grid.
Why it still matters in 2026
On long-form content like documentation, articles, and product pages, consistent vertical spacing is one of the clearest signs that a page was set with care. Reading is easier when the eye can predict where the next line will land. When the grid breaks, the content feels amateurish even when you cannot name why.
Vertical rhythm also makes responsive design easier. Pick the base unit at the smallest viewport, scale every typographic measurement against it, and the proportions hold up at every size. Pair it with a fluid type scale and you get a page that feels handcrafted at every breakpoint.
Common Use Cases
Documentation site authors use the Calculator to set up a tight rhythm before they write a line of CSS. Marketing landing-page designers use it to align a multi-column hero section where each column has different content lengths but identical baselines. Email template designers use it to keep table-based layouts visually consistent in clients that do not support modern CSS.
Teams migrating to a design-token system find the Calculator useful as a single source of truth for the spacing scale. Export the values, paste them into your token file, and never again debate whether the small gap should be 8 or 10 pixels.
Worked example: box tops and baselines in Chromium
What the tool does: every block gets a line-height rounded up to the base unit (font size × multiplier), headings a top margin of font size × 1.2 rounded up and two base units below, body text, lists, quotes and code one body line below, and code blocks padding of two base units. All sizes are editable, the output can be px or rem, and inline small gets line-height 1 so it never makes its line taller. That puts every box top on the grid. Baselines need one more step: a line box puts its text in the middle (half the extra leading above it), and the font's ascent decides where the baseline falls, so with Put baselines on the grid ticked the tool lays out each element in your browser with the font you name (or the font file you load), reads where its baseline lands, and adds position: relative; top to move the text down to the next grid line. Relative positioning leaves the box where it was, so nothing below moves.
On October 13, 2026 we pasted the copied CSS into a blank Chromium page, gave each element two lines of text with a zero-size marker at the start of each line, and measured how far every box top and baseline sat from the nearest grid line. Defaults shown: 8 px base, 1.5, Liberation Sans; the old column is the previous version of this tool (fixed sizes, px only, no offsets).
| Element | Font px | Line px | Baseline off grid, old (px) | Offset added (px) | Baseline off grid, now (px) |
|---|---|---|---|---|---|
| h1 | 48 | 72 | 4 | 4 | 0 |
| h2 | 36 | 56 | 0 | 0 | 0 |
| h3 | 28 | 48 | 1 | 7 | 0 |
| h4 | 22 | 40 | 3 | 5 | 0 |
| h5 | 18 | 32 | 2 | 2 | 0 |
| p | 16 | 24 | 1 | 7 | 0 |
| p with a <small> | 16 | 24 | 3 / 4 | 7 | 0 |
| pre (code, 14) | 14 | 24 | not covered | 7 | 0 |
| li | 16 | 24 | not covered | 7 | 0 |
- Every baseline on a grid line, in four set-ups. Liberation Sans (8 px, 1.5), DejaVu Serif (6 px, 1.4), Liberation Serif in rem (4 px, 1.6) and DejaVu Sans loaded through the file input (8 px, 1.5): 9 elements × 2 lines each, 0 px off in all four. Box tops were on the grid in both versions.
- The old
smallrule pushed lines apart. It gave the 13 px text a 24 px line-height of its own, which sits lower than the paragraph's and makes that line taller: the second line of the paragraph moved a further pixel off the grid. Line-height 1 keeps it inside the paragraph's line. - Offsets belong to one font. They come from that font's ascent and descent, so a fallback font, a different weight file or another family puts baselines elsewhere; the CSS comment names the font it was measured with. The tool measures in your browser, so a web font has to be installed or loaded with the file input, otherwise the browser's fallback is what gets measured.
- rem output scales the whole grid. At a 20 px browser default every value, offsets included, grows by 1.25, so the grid becomes 10 px. Browsers round the font's ascent to whole pixels at each size, so offsets can be up to about a pixel out at a root other than the one you set.
- Anything with a vertical border or a fixed height breaks the count unless that height is a multiple of the base unit; the code block uses padding and a background for that reason, and the quote's border is on the left only. Images need heights that are multiples too.
- The other route is
text-box-trim(Chrome and Edge 133, Safari 18.2, Firefox 154 per MDN), which trims a block to its cap height and baseline so spacing can be measured from the text itself. It changes block heights per font, so it does not combine with a line-height grid like this one; the tool does not write it.
Sources
Checked on .