Sub topic 6
Baseline Grids and Vertical Rhythm
This chapter assumes you know point size, leading and line length, and that you can use a layout tool such as InDesign, Affinity Publisher or Figma. The CSS examples assume basic HTML and CSS. By the end you will be able to build a baseline grid, align text across columns to it, and approximate it on screen.
What a baseline grid is
A baseline is the invisible line that the bottoms of most letters sit on. A baseline grid is a set of evenly spaced horizontal lines that runs down the page. Every line of body text sits on one of these lines.
Column grids organize the page left to right. A baseline grid organizes it top to bottom. The two work together. When body text in neighboring columns shares one baseline grid, the lines in each column sit at the same heights, so the text looks like one ordered surface.
The main benefit shows in multi-column layouts. Without a shared grid, a line in column one sits slightly higher or lower than its neighbor in column two. The misalignment is small, but readers see a ragged texture across the page. In print it also causes show-through: on thin paper, lines on the back of a sheet fall between the lines on the front and make the text harder to read. Aligned baselines on both sides reduce this.
Choosing the baseline unit
The baseline unit is the distance between two grid lines. It usually equals the leading of your body text. For 10 pt text with 12 pt leading, the unit is 12 pt.
Pick the unit from the body text first, and do not pick it from the page. Follow these steps:
- Choose the body type size for the reading distance and line length (see the earlier chapter on line length).
- Set comfortable leading, usually 120% to 150% of the type size for body text.
- Round the leading to a convenient whole number. That number is the baseline unit.
Every other vertical measurement should then be a multiple of the unit. Headings, captions, space between paragraphs and image heights all snap to it.
| Element | Size | Leading | Baseline units |
|---|---|---|---|
| Body text | 10 pt | 12 pt | 1 |
| Caption | 8 pt | 12 pt | 1 |
| Subheading | 12 pt | 12 pt | 1 |
| Heading | 20 pt | 24 pt | 2 |
| Space between sections | 24 pt | 2 |
Notice that the caption has smaller type but the same leading as the body. This keeps its lines on the grid. You can also give small text half-unit leading, such as 6 pt, only if every line of the small text still lands on a grid line in the end. That is hard to guarantee, so a whole-unit leading is the safer choice.
Fitting the grid to the page
A baseline grid starts at the top margin and ends at the bottom margin. The text area height should be a whole number of baseline units. Otherwise the last line of text does not land on the bottom margin, and the grid leaves an uneven gap.
Compute the number of lines that fit:
def baseline_lines(page_height, top_margin, bottom_margin, unit):
"""Return how many baseline lines fit and the leftover space."""
text_height = page_height - top_margin - bottom_margin
lines = int(text_height // unit)
leftover = text_height - lines * unit
return lines, leftover
# A4 portrait is 297 mm tall. Use points: 1 mm = 2.83465 pt.
mm = 2.83465
page = 297 * mm
lines, leftover = baseline_lines(page, 20 * mm, 25 * mm, 12)
print(lines, round(leftover, 2))The leftover is the amount you must absorb. The usual fix is to adjust the bottom margin by that amount so that the text area becomes an exact multiple of the unit. A bottom margin that is a few points larger than planned is almost never noticeable.
Aligning text across columns
Once the grid exists, each text frame has to be told to use it. In InDesign this is the "Align to Baseline Grid" option in a paragraph style. Affinity Publisher has a similar option under the text baseline grid settings. Figma has no baseline grid for text, so you set line heights and frame positions by hand using multiples of the unit.
The main rules are:
- Make all body styles use the same leading, equal to the baseline unit.
- Make space before and after paragraphs a multiple of the unit, or use none and rely on a blank line.
- Make heading leading a multiple of the unit, so the text after a heading returns to the grid.
- Align the first baseline of each text frame to the grid. Set the frame's first baseline offset to "Leading" or "Ascent" so the first line sits on a grid line.
If a heading has a different leading that is not a multiple of the unit, every paragraph below it shifts off the grid. This is the most common cause of a "broken" baseline grid. Check the heading styles first when the text stops aligning.
Images and the baseline grid
Images do not have baselines, but they affect the lines below them. Suppose an image is 100 pt tall, and the unit is 12 pt. The text beneath it starts 100 pt lower, and 100 is not a multiple of 12. The text under the image is now off the grid.
There are two fixes. You can resize the image so that its height, plus any space around it, is a multiple of the unit. For example, 96 pt is exactly 8 units. Or you can lock the image to the grid by letting the frame's height snap to a multiple. In a modular grid, the module height is designed to be a multiple of the unit for this reason, so images that fill whole modules never disturb the text.
Vertical rhythm on screen
On the web, a true baseline grid is hard to get. Browsers place text inside line boxes, and the baseline position depends on the font's metrics, so two fonts with the same line height put their baselines at slightly different places. CSS has no built-in baseline grid feature.
What you can build is vertical rhythm. This means the vertical spacing is based on a single unit, so the text lines repeat at regular intervals. It is an approximation of a baseline grid. For most pages it is close enough.
:root {
--unit: 1.5rem;
}
body {
font-size: 1rem;
line-height: var(--unit);
}
p, h2, figure {
margin-block: 0 var(--unit);
}
h2 {
font-size: 1.5rem;
line-height: calc(var(--unit) * 2);
}This builds on the idea from the spine example: line height and margins are multiples of one 1.5 rem unit. The heading gets two units of line height, so after it the text returns to the rhythm. Using rem keeps the rhythm intact when users change their default font size, because the unit grows with the text.
Where screen rhythm breaks
Rhythm fails in predictable places. Know them before you debug.
- Borders and padding. A 1 px border adds 1 px to the height of an element and shifts everything below it by 1 px. Use an inset
box-shadoworoutline, or subtract the border width from the padding. - Images. An image keeps its intrinsic ratio, so its height is rarely a multiple of the unit. Use
aspect-ratiowithobject-fit: coverand set the height to a multiple of the unit, or accept the shift and add a spacer. - Fonts with different metrics. A fallback font may have a different x-height, so lines look unevenly spaced even though the line boxes are even.
- Fluid type. If font size uses
clamp()and line height is fixed, the ratio between them changes with the viewport. The lines can look too tight or too loose at the extremes. - Inline elements. Superscripts, large inline icons and mixed font sizes can make a line box taller than the unit. Set
line-heighton those elements to0or to the unit, or usevertical-aligncarefully.
Baseline grid and modular grid together
A modular grid divides the page into modules, which are rows and columns that form a repeating block. The rows work best when each module height is a whole number of baseline units, plus the gutter between rows if the gutter is also a multiple of the unit.
For example, take a 12 pt unit. A module might hold 15 lines, which is 180 pt. A vertical gutter of 12 pt (one line) separates modules. Each row then repeats every 192 pt, which is 16 units. The text in every module lines up with text in every other module, across rows and columns.
def module_height(lines, unit, row_gutter_units=1):
"""Return module height and the row pitch in the same unit as `unit`."""
height = lines * unit
pitch = height + row_gutter_units * unit
return height, pitch
print(module_height(15, 12)) # (180, 192)If you set the gutter to a value that is not a multiple of the unit, such as 10 pt, the text in the second row drifts off the grid by 10 pt minus the nearest multiple. The fix is to make the gutter a multiple of the unit.
Checking your work
Before you finish a layout, run these checks:
- Turn on the baseline grid overlay. Confirm that body text sits on the lines in every column.
- Look at the first line after each heading, image and pull quote. These are where the grid usually breaks.
- Check the last line of the text area. It should end on the bottom margin.
- On screen, add a temporary background with a repeating gradient the height of the unit and look for drift.
.debug-rhythm {
background-image: repeating-linear-gradient(
to bottom,
rgb(255 0 0 / 0.25) 0,
rgb(255 0 0 / 0.25) 1px,
transparent 1px,
transparent var(--unit)
);
}Add the debug-rhythm class to body and remove it before publishing.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| Heading leading not a multiple of the unit | All text below shifts off the grid | Set heading leading to 1, 2 or 3 units |
| Text area height not a whole number of units | Last line misses the bottom margin | Adjust the bottom margin |
| Image heights ignore the unit | Text under images is off the grid | Size images to whole units |
| Gutter between rows is not a multiple of the unit | Second and later rows drift | Make the row gutter a multiple of the unit |
| Pixel-based line height on screen | Rhythm breaks when users change font size | Use `rem` |
Exercise
A layout uses 9 pt body text with 12 pt leading on a page whose text area is 600 pt tall. A heading uses 18 pt type with 20 pt leading. (a) How many baseline lines fit, and what is the leftover space? (b) Why does the heading break the grid, and what leading would fix it?
Show answer
(a) The unit is 12 pt. 600 / 12 = 50, so 50 lines fit with 0 pt left over. (b) 20 pt is not a multiple of 12, so each heading pushes the text below it 8 pt off the nearest grid line (20 - 12 = 8). Setting the heading leading to 24 pt (2 units) keeps following text on the grid.
Exercise
A web page uses a 1.5rem unit. A card has a 1px border and 1.5rem padding on all sides, and the text inside it has a line height of 1.5rem. Why does the content below the card drift, and name one way to avoid it?
Show answer
The 1px top and bottom borders add 2px to the card's height, so its height is no longer a multiple of the unit and everything below it shifts. Replace the border with an inset box-shadow or outline, which takes no layout space, or reduce the padding by the border width.