Sub topic 6
Baseline Grids and Vertical Rhythm
This chapter assumes you know point size, leading (the distance from one text baseline to the next), and line length. It also assumes you can read basic CSS. A multi-column grid controls horizontal structure. A baseline grid controls vertical structure, so text lines in neighboring columns sit on the same lines.
What a baseline grid does
A baseline grid is a set of evenly spaced horizontal lines. Each line of body text sits on one of them. The spacing between lines equals the body leading.
Without one, a two-column page drifts. A heading with different leading pushes the text beneath it off the lines of the neighboring column. The two columns then look misaligned, and on thin paper the text of the reverse side shows through between the lines.
With a baseline grid, every element snaps to the same lines. Headings, captions, and images must occupy a whole number of baseline units.
Choosing the baseline unit
Start from the body text. If the body is 10 pt type on 12 pt leading, the baseline unit is 12 pt. Page height, margins, and the number of rows in a modular grid should then be multiples of that unit.
Use this order of work:
- Choose body size and leading for comfortable reading.
- Set the baseline unit equal to that leading.
- Size headings so their leading is a multiple of the unit (24 pt for a 12 pt unit).
- Set space before and after elements in whole units.
- Fit image heights and modular rows to whole units.
Checking that the grid fits the page
The usable page height should divide evenly by the unit. If it does not, the last line falls short and a gap remains at the bottom. You can adjust the margins slightly to fix this.
def baseline_fit(page_height, top_margin, bottom_margin, unit):
"""Return how many baseline lines fit and the leftover height."""
usable = page_height - top_margin - bottom_margin
lines = int(usable // unit)
leftover = usable - lines * unit
return lines, leftover
# A4 portrait is 297 mm tall. A 12 pt unit is about 4.233 mm.
unit_mm = 12 * 25.4 / 72
print(baseline_fit(297, 20, 25, unit_mm))A leftover near zero means the grid fits. A large leftover can be absorbed by enlarging the bottom margin. Leftover space is acceptable at the foot of a page, where it reads as margin.
Vertical rhythm on screen
Browsers have no baseline grid feature. You approximate one by making every line height and vertical spacing a multiple of one base unit.
body {
font-size: 1rem;
line-height: 1.5rem;
}
p, h2, figure {
margin-block: 0 1.5rem;
}Here the unit is 1.5rem. Each paragraph line takes one unit, and each block is followed by one unit of space. This gives a consistent rhythm, but it is only an approximation. A heading with a larger font size needs its own line height set to a multiple of the unit, for example line-height: 3rem. Images need heights that are multiples too, or the lines after them shift off the rhythm.
Common errors
- Setting the unit from the heading. The unit comes from body text, because body text makes up most of the lines.
- Fractional spacing. A gap of 1.3 units pushes every following line off the grid.
- Ignoring images. A photo of arbitrary height breaks the rhythm for everything below it. Crop to whole units or add padding.
- Forcing every element onto the grid. Captions and footnotes in smaller type may use a half unit, if they are aligned consistently.
- Assuming screens match exactly. Users can change text size, so rhythm in CSS holds only for the default settings.
Linking to modular grids
A modular grid divides the page into modules separated by gutters. Make each module height a whole number of baseline units, with the vertical gutter also a whole number of units. Then the first line of text in each module lines up with the first line in the module beside it.
For example, with a 12 pt unit, a module of 15 units (180 pt) and a gutter of 1 unit (12 pt) keep every row on the grid.
Exercise
A page has 10 pt body text on 14 pt leading. You want a heading with 22 pt leading and 14 pt of space below each paragraph. Which of these values break the baseline grid, and how would you fix them?
Show answer
The baseline unit is 14 pt. The 14 pt paragraph spacing is one unit, so it fits. The 22 pt heading leading is not a multiple of 14, so it breaks the grid. Change it to 28 pt (two units), or reduce it to 14 pt, so the text after the heading still lands on a grid line.