Sub topic 8
Modular grids
A modular grid divides a page into columns and rows. The two sets of lines cross to form a field of equal cells called modules. This chapter assumes you know what columns, gutters and margins are, and that you can read the column-width formula from the earlier chapters. It also assumes you have met leading and baseline grids, and can read basic CSS Grid syntax.
What a modular grid adds
A multi-column grid controls horizontal position only. Text and images can start at any height. A modular grid adds fixed horizontal divisions as well. Every element now has a position in two dimensions, and its top edge, bottom edge, left edge and right edge all land on grid lines.
This suits content made of many small, varied items. Calendars, newspapers, timetables, product catalogues, dashboards and image-heavy magazines are typical examples. Because every module is the same size, designers can combine modules into larger blocks while keeping the whole page consistent.
Anatomy of a module
A module is the rectangle bounded by two adjacent column lines and two adjacent row lines. Gutters separate modules horizontally. Between rows there is a vertical gap, sometimes called the row gutter, which is usually the same size as the column gutter.
Three terms matter when you plan one:
- Module: one cell of the grid.
- Block (or field): a rectangle made of several modules, such as 2 columns by 3 rows.
- Flowline: a horizontal line that crosses the page at a fixed height. Flowlines are often used to align the top of images, headlines or the start of body text across the whole page.
Unlike a column, a module has a height. That height is the main new decision.
Choosing the module height
Row height should relate to the text, not to an arbitrary number. The most reliable method is to make each module an exact number of baseline lines, plus the gaps between rows. That way, text in neighbouring modules stays on the same baselines.
Suppose body text uses 12 pt type on 14 pt leading, so the baseline unit is 14 pt. If you want a row gap of one baseline unit and each module to hold 8 lines of text:
- Module height = 8 × 14 = 112 pt
- Row gap = 14 pt
- Row pitch (module height plus gap) = 126 pt, which is exactly 9 baseline units
Because the pitch is a whole number of baseline units, the first line of text in every row sits on the baseline grid. If the pitch were 125 pt, lines in lower rows would drift off the grid by 1 pt per row.
Calculating a module grid
The column width formula from the grid maths chapter applies to rows as well. The formula has the same shape in both directions:
module size = (usable length − (count − 1) × gutter) / count
The script below solves for the module height when you know the usable page height, the row count, the gap, and the baseline unit. It also rounds the result down to a whole number of baseline units, then reports the leftover space.
def module_height(usable_height, rows, gap, baseline):
"""Largest module height that makes (height + gap) a multiple of baseline.
Returns (module_height, leftover) in the same unit as the inputs.
The gap must itself be a multiple of the baseline unit.
"""
if gap % baseline != 0:
raise ValueError("gap must be a multiple of the baseline unit")
raw = (usable_height - (rows - 1) * gap) / rows
lines = int(raw // baseline)
height = lines * baseline
leftover = usable_height - (rows * height + (rows - 1) * gap)
return height, leftover
# A4 portrait is 297 mm tall. Use 15 mm top and bottom margins,
# so the usable height is 267 mm. Baseline unit 4.939 mm (14 pt),
# gap of one baseline unit, 6 rows.
baseline_mm = 14 * 25.4 / 72
height, leftover = module_height(267, 6, baseline_mm, baseline_mm)
print(round(height, 2), round(leftover, 2))Run it and you get a module height of about 34.57 mm (seven baseline units) and roughly 4.8 mm of leftover space. That leftover has to go somewhere. The usual choices are to add it to the bottom margin, split it between the top and bottom margins, or reduce the row count by one and try again. Do not stretch the gaps, because that breaks the baseline relationship.
Common module counts
The right number of modules depends on how much variety the content needs. Too few modules and the grid gives you almost no choices. Too many and it stops guiding your decisions.
| Grid | Modules | Typical use |
|---|---|---|
| 2 × 2 | 4 | Posters, simple covers |
| 3 × 3 | 9 | Photo layouts, simple reports |
| 4 × 6 | 24 | Magazines, newsletters |
| 6 × 8 | 48 | Newspapers, catalogues, data-heavy pages |
| 12 × 12 | 144 | Dashboards, complex web interfaces |
A useful rule is to choose a count with several factors. For example, 12 divides into 2, 3, 4 and 6, so a 12-column grid supports halves, thirds, quarters and sixths. A 7-column grid offers almost no even splits.
Placing content on modules
Once the grid exists, each element gets a block. The decisions are about span, not about exact coordinates.
- Decide the dominant element first, such as the lead image. Give it the largest block.
- Assign supporting images to smaller blocks, using sizes that repeat. Repetition makes a page look planned.
- Let text fill the remaining modules. Check that the column width still gives a comfortable line length.
- Leave some modules empty on purpose. Unused modules create white space and rest points.
A feature image of 2 columns by 3 rows sits beside a caption that spans 2 columns on the first row. In CSS Grid, that arrangement is direct to write:
.modular {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(6, 8rem);
gap: 1rem;
}
.feature { grid-column: 1 / span 2; grid-row: 1 / span 3; }
.caption { grid-column: 3 / span 2; grid-row: 1; }Notice that .feature and .caption share the same top line, because both begin on row 1. That shared edge is a flowline. The caption is only one module high, so the space under it, rows 2 and 3 in columns 3 and 4, is available for other items.
Common errors
- Rows that ignore the type. If the module height is not tied to the leading, text in adjacent modules falls out of alignment. Fix the module height from the baseline unit, as in the script above.
- Gaps that differ between directions. A column gutter of 5 mm and a row gap of 3 mm looks accidental. Use the same value unless you have a reason not to.
- Modules too small. If a typical text block needs five or six modules to hold a readable paragraph, the grid is too fine. Merge rows or reduce the count.
- Modules too large. If every element fills exactly one module, the page looks like a table. Use varied spans.
- Treating the grid as a cage. Placing an image so it covers the gutter looks like a mistake only if it is unintentional. A later chapter covers breaking the grid on purpose.
- Fixed row heights with variable content. On screens,
8remrows will clip text that is longer than expected. For web layouts, considerminmax(8rem, auto)so rows can grow.
A modular grid on the screen
The same logic carries over to digital layouts, with one change. Rows are often flexible. A common compromise is to fix the column structure and let row heights follow the content, while keeping a consistent row gap and a shared vertical rhythm from the baseline unit. That gives you the alignment benefits across columns without clipping content.
.catalogue {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-auto-rows: minmax(8rem, auto);
gap: 1.5rem;
}
.tile { grid-column: span 1; }
.tile--wide { grid-column: span 2; }
.tile--hero { grid-column: span 2; grid-row: span 2; }Here, grid-auto-rows creates rows as items require them. The hero tile spans two rows, so it takes the combined height of two rows and the gap between them.
Checking a modular layout
Review a finished page against these questions:
- Do all edges of images and text blocks land on module edges?
- Do the first lines of text in neighbouring blocks share baselines?
- Are block sizes drawn from a small set that repeats?
- Is the empty space intentional, and spread across the page instead of left in one corner?
- Does every block still work if its content grows by 20 percent?
If several answers are no, revise the grid before moving elements around. A grid that keeps fighting the content usually has the wrong module size or count.
Exercise
A page has a usable height of 240 mm and a baseline unit of 5 mm. You want 5 rows with a gap of 5 mm between them, and each module height must be a whole number of baseline units. What is the largest module height, and how much space is left over?
Show answer
Raw module height = (240 − 4 × 5) / 5 = 44 mm. That is 8.8 baseline units, so round down to 8 units = 40 mm. The grid then uses 5 × 40 + 4 × 5 = 220 mm, leaving 240 − 220 = 20 mm. Add the leftover to the margins, or try 6 rows instead: (240 − 25) / 6 = 35.8 mm, which rounds down to 7 units = 35 mm, using 6 × 35 + 5 × 5 = 235 mm and leaving 5 mm.
Exercise
Why can a modular grid with fixed 8rem row heights fail on a web page, and what CSS change reduces the risk while keeping a minimum row height?
Show answer
Text can wrap onto more lines when the window is narrow or the user enlarges the text, so content may be taller than 8rem and get clipped or overflow. Using grid-auto-rows: minmax(8rem, auto) keeps a minimum height of 8rem but lets each row grow to fit its content.