Sub topic 9
Placing Text and Images Across Columns and Modules
This chapter assumes you know the parts of a grid (margins, columns, gutters, rows, modules) and basic typography terms such as point size and leading. You should also be able to read simple CSS. Here you learn how to place content on a grid by spanning it across columns and modules, and how to avoid the errors that come with spanning.
What spanning means
A grid only organizes a page when content is attached to it. Spanning means a block of text or an image covers more than one column or module. It always covers whole units plus the gutters between them. It never ends in the middle of a column.
A block that spans n columns has this width:
width = n × column width + (n − 1) × gutter
The gutters inside the span belong to the block. This is why a two-column image is wider than twice one column. It also explains why a block that spans two columns lines up exactly with the edges of the two single-column blocks above or below it.
The function below applies the formula. It reuses the column calculation from the grid math chapter.
def column_width(page_width, margin, gutter, columns):
"""Width of one column when both side margins are equal."""
usable = page_width - 2 * margin
return (usable - (columns - 1) * gutter) / columns
def span_width(col_width, gutter, n):
"""Width of a block that spans n columns."""
return n * col_width + (n - 1) * gutter
col = column_width(210, 20, 5, 4) # 38.75 mm
print(span_width(col, 5, 1)) # 38.75
print(span_width(col, 5, 2)) # 82.5
print(span_width(col, 5, 4)) # 170.0A four-column span returns 170 mm. That is the full usable width of an A4 page with 20 mm margins. This is a quick check: a span of all columns must equal the usable width.
Spanning on a multi-column grid
On a multi-column grid you span horizontally. Rows are not fixed, so text and images flow down the page and set their own height.
Common spans on a 12-column grid:
| Content | Typical span | Reason |
|---|---|---|
| Body text | 6 to 8 columns | Keeps the line length readable |
| Sidebar or note | 3 to 4 columns | Leaves a clear secondary column |
| Inline image | 4 to 8 columns | Sits beside or above text |
| Full-width image | 12 columns | Marks a break in the content |
| Pull quote | 4 to 6 columns | Contrasts with the text width |
The first row of the table matters most. Text sets the span, as the earlier chapter on line length explained. Pick the text span first, then fit images around it.
Here is a 12-column layout in CSS. The article takes eight columns and the sidebar takes four.
.columns {
display: grid;
grid-template-columns: repeat(12, 1fr);
column-gap: 1.5rem;
max-width: 72rem;
margin-inline: auto;
}
.article { grid-column: 1 / span 8; }
.sidebar { grid-column: 9 / span 4; }In grid-column: 1 / span 8, the number 1 is the starting grid line and span 8 is the number of columns covered. Grid lines are numbered, and a grid with 12 columns has 13 lines. Starting at line 9 and spanning 4 columns ends at line 13, which is the right edge of the grid.
Spanning on a modular grid
A modular grid also has fixed rows, so a block spans in two directions. It covers a rectangle of modules. The block's height is then the number of rows times the module height, plus the gutters between rows.
.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; }The feature image covers two columns and three rows, which is six modules. The caption sits beside it in the first row.
The same formula works vertically. With rows of 8 rem and a gap of 1 rem, the three-row feature is 3 × 8 + 2 × 1 = 26 rem tall. Its width comes from the column formula. You can compute the aspect ratio of any module block before you choose or crop the image.
def block_size(col_w, row_h, gutter, cols, rows):
"""Width and height of a block that spans cols x rows modules."""
w = cols * col_w + (cols - 1) * gutter
h = rows * row_h + (rows - 1) * gutter
return w, h
w, h = block_size(col_w=38.75, row_h=40, gutter=5, cols=2, rows=3)
print(w, h, round(w / h, 3)) # 82.5 130.0 0.635The result is a portrait block with a ratio of about 0.635. A landscape photograph needs to be cropped to fit it, or the block needs a different span. Adjust the span rather than distort the picture.
Aligning text and images to the grid
Spanning controls the sides of a block. Alignment controls how its contents sit inside it. These rules keep a layout consistent:
- Images fill the span edge to edge. Their edges touch the column edges, not the gutters.
- Text blocks start at a column's left edge. Do not indent a text block by a fraction of a gutter.
- Captions share the span of the image they describe, or a single column under it.
- Heights follow the rows. On a modular grid an image is cropped to a whole number of modules. On a column grid, the bottom edge of an image should land on a baseline.
The last rule connects spanning to the baseline grid. If an image is 130 mm tall and the baseline unit is 4.5 mm, the image ends between two baselines. The text below it then falls off the rhythm for the rest of the column. Round the image height to a multiple of the baseline unit, or add space below it that makes up the difference.
body {
font-size: 1rem;
line-height: 1.5rem;
}
p, h2, figure {
margin-block: 0 1.5rem;
}In the CSS above, every block ends on a multiple of 1.5 rem. An image with an arbitrary height breaks this, so give figures a height that is a multiple of 1.5 rem, or use aspect-ratio together with a fixed width and check the result.
Choosing span sizes
Spans also set emphasis. A wider block reads as more important. Use this as a deliberate choice, not an accident:
- Use one dominant block per page or spread. It gives the eye a starting point.
- Use two or three distinct sizes. If every image has a different span, the grid becomes invisible.
- Pair a large block with a small one. The contrast creates hierarchy.
- Repeat spans for items of equal importance, such as a row of product photos.
A useful method is to sketch the layout as a rectangle diagram first. Mark each block with its column and row range. Only then place real content.
Common errors
Spans that ignore gutters. A designer divides the width by the number of columns and forgets the internal gutters. The block ends short of the column edge. Always use the span formula.
Text spans that are too wide. Spanning body text across ten of twelve columns gives lines of 120 characters or more. Readers lose their place at the line break. Keep a single text block near 45 to 75 characters per line, and use more columns only for display text or multi-column text blocks.
Orphan modules. On a modular grid, a layout leaves one empty module that matches nothing around it. Either fill it with a small element or merge it into a larger block.
Images that are stretched. A designer forces a photo into a span with a different ratio. Crop instead, and keep the aspect ratio of the original.
Spans that cross the binding. In print, a span that crosses the center of a spread runs into the binding margin. A later chapter covers this. For now, avoid placing faces or key text in the gutter between facing pages.
Fixed rows with variable text. In a modular grid, text inside a module can overflow. Set the number of lines per module in advance, using the line height, so that text fills a whole number of lines.
Spanning in a fluid layout
On screens, the column count changes with the viewport width, so a fixed span can mean different things. A block that spans 8 of 12 columns on a desktop would span 8 of 8 on a tablet. Define spans per breakpoint, or use spans that stay valid across counts. The responsive chapter covers this in depth.
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
}
@media (min-width: 48em) {
.grid { grid-template-columns: repeat(8, 1fr); }
}
@media (min-width: 64em) {
.grid { grid-template-columns: repeat(12, 1fr); gap: 1.5rem; }
}With this grid, a block set to grid-column: 1 / -1 always spans the full width, whatever the column count. A block set to span 4 is the full width on a phone, half on a tablet and a third on a desktop. Pick the span that suits each size, and write it inside the media query.
Exercise
A page is 297 mm wide with 15 mm margins, 6 mm gutters and 6 columns. How wide is a block that spans 3 columns? Show the column width first.
Show answer
Usable width is 297 − 2 × 15 = 267 mm. Five gutters take 30 mm, so the six columns share 237 mm and each is 39.5 mm. The 3-column span is 3 × 39.5 + 2 × 6 = 130.5 mm.
Exercise
A modular grid has 8 rem rows and a 1 rem gap. An image spans 4 rows. What is its height, and why is it not 32 rem?
Show answer
The height is 4 × 8 + 3 × 1 = 35 rem. The span includes the three gaps between the four rows, so it is taller than four rows alone.
Exercise
A figure on a 1.5 rem baseline grid is 10.4 rem tall. What goes wrong below it, and what are two ways to fix it?
Show answer
10.4 rem is not a multiple of 1.5 rem (it falls between 9 rem and 10.5 rem), so the text under the figure sits off the baseline rhythm. Fix it by making the figure 10.5 rem tall, or by adding 0.1 rem of space below it, so the next line starts on a baseline.