Skip to content
← Typography Tools

Vertical Rhythm Calculator

Lock body text, headlines, and margins onto a single baseline grid so that every line of content lines up across columns and devices.

Related Tools

Related Tool
Line Height Calculator
Related Tool
Typography Scale
Related Tool
Responsive Type Calculator
Related Tool
CSS Tools

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).

ElementFont pxLine pxBaseline off grid, old (px)Offset added (px)Baseline off grid, now (px)
h14872440
h23656000
h32848170
h42240350
h51832220
p1624170
p with a <small>16243 / 470
pre (code, 14)1424not covered70
li1624not covered70

Frequently Asked Questions

What is a baseline grid?
A baseline grid is an evenly spaced set of horizontal lines that every line of text sits on. The distance between adjacent lines is the base unit, often equal to the body text line-height. On a 4-pixel grid every measurement is a multiple of 4; on a 24-pixel grid every line of text starts exactly 24 pixels below the previous one.
Should I use pixels or rems for my baseline?
Rems for production, because they follow the reader's browser font-size setting. Choose rem under Output units and set the root size you design at (16 px by default): every size, line-height, margin and offset is divided by it, so the whole grid scales together when the reader changes their default (16 px base 8 becomes 0.5rem; at a 20 px default it is 10 px).
What is the right base unit?
Most teams settle on a base unit between 4 and 8 pixels, with body line-height as a multiple of it. A 4-pixel base gives the most flexibility because every common margin (8, 12, 16, 20, 24, 32) is a whole multiple. An 8-pixel base is a popular default because it cleanly halves and quarters into 4, 2, and 1. Start with 4-pixel base and adjust if it feels too granular.
How do headings fit on a baseline grid?
Each heading's line-height is its font size times the multiplier, rounded up to the next multiple of the base unit (8 px base, 1.5: a 48 px h1 gets 72 px, a 36 px h2 56 px), and its margins are multiples too, so every line box starts on the grid. Where the baseline falls inside that box depends on the font, so the tool can measure it in your browser and add a small position: relative; top offset per element that puts the text on a grid line without moving anything else.
Does this work with fluid typography?
Not directly. The tool works with fixed sizes, so a clamp() font size changes between viewports and drifts off the grid; the measured offsets also only hold for the sizes they were measured at. A common workaround is a unitless line-height multiplier on fluid text, with margins in rem multiples of the base unit, accepting that headings are only approximately on the grid.
What about content I do not control, like user comments?
Apply the rhythm's CSS to a parent container (for example .comments p, .comments h3) so user-supplied HTML inherits it. The output covers headings, paragraphs, lists, blockquotes, code blocks and inline small text; images and anything with a vertical border or fixed height need a height that is a multiple of the base unit, or everything below them moves off the grid.
Will breaking the rhythm always look bad?
No. Intentional rhythm breaks are how you create emphasis. A pull quote that floats off the grid draws the eye precisely because the rest of the page is so regular. The rule is: build the grid first, hold it for body content, and only break it on deliberate design moments. A page that breaks the grid by accident on every other element feels chaotic.
How do I check if my rhythm is actually working?
The tool's preview applies the copied CSS to sample content over grid lines every base unit, so text should sit on the lines. For your site, add a temporary background to the page, such as background-image: linear-gradient(to bottom, rgba(255,0,0,.3) 1px, transparent 1px) with background-size: 100% 8px, check that baselines touch the lines, and use DevTools' box model to find any margin, border or height that is not a multiple.