Calculate equal column width from container width, number of columns and gutter size, with span widths, or estimate a readable text column width.
- All Construction Calculators
- Class Width Calculator
- Column Volume Calculator
- Scale Calculator
- Line Height Calculator
- Shelf Spacing Calculator
Calculator Functions
| Function | What it does | What it requires |
|---|---|---|
| Grid and gutters | Finds the width of each column in an equal-column layout, with the width of every column span | Requires the container width and the number of columns, with the gutter between columns and the left and right edge margins as options |
| Text width estimate | Estimates the column width that holds a target number of characters per line, and how many such columns fit a container | Requires the font size in CSS px, the target characters per line and the average glyph width as a fraction of the font size; a container width, gutter and edge margins are optional |
Widths can be entered in px, in, cm or mm and are converted with the CSS reference units, 1 in = 96 px = 2.54 cm [1]. Blank gutters and margins count as zero in the grid function. Each result is also listed in all four units with a matching CSS example.
Column Width Formulas
(N − 1) × G) ÷ N
| CW | Width of one column |
| W | Container width |
| ML, MR | Left and right edge margins |
| N | Number of columns |
| G | Gutter between columns |
Grid and gutters
A 1,000 px container with 20 px edge margins, 4 columns and 20 px gutters leaves 1,000 − 40 − 60 = 900 px for the columns, so each is 225 px wide. A block that spans k columns is k × CW + (k − 1) × G wide: two columns span 470 px, about 49% of the 960 px between the margins. With no margins or gutters the formula reduces to W ÷ N.
Text width estimate
F is the font size in px, CPL is the target characters per line and A is the average glyph width as a fraction of the font size. A 16 px font at 66 characters per line with the default A of 0.5 gives 528 px. The 0.5 default is a rough average, and it equals the fallback width CSS gives the ch unit when the “0” glyph cannot be measured [1]. The ch unit measures the advance of the “0” glyph, not the average character [1], so a width set in ch is not an exact character count either.
(U + G) ÷ (Width + G))) [2]
With a container width entered, the function also finds how many columns of that width fit. U is the container width less the edge margins and G is the gutter, 24 px unless changed. This is the rule CSS multi-column layout follows when a column width is set and the column count is automatic, and the columns then widen to (U − (N − 1) × G) ÷ N to fill the space [2]. A 1,200 px container fits 2 columns of 528 px, each widened to 588 px, about 73.5 characters per line. A container narrower than the target still gets one column, narrower than the target [2].
Limits of This Estimate
- CSS px is a reference unit. One inch is 96 px by definition, but on a screen the px is tied to the device pixels, not to a ruler, so an inch in CSS need not measure an inch [1].
- The grid result is the content width of a column at the entered container width. Borders and padding on the columns are not included, and a narrower responsive container changes the result.
- The text estimate rests on an average glyph width. The real number of characters per line depends on the font, the text, spacing and wrapping. These estimates are based on the best available data and estimations.
Sources
- World Wide Web Consortium (W3C), CSS Values and Units Module Level 3, sections 5.1.1 and 5.2: absolute length units, the reference pixel and the ch unit
- World Wide Web Consortium (W3C), CSS Multi-column Layout Module Level 1, sections 3.1 and 3.4: number of columns that fit and the used column width
