Layout Grid Calculator

Enter a container width, the number of columns and the gutter to get the exact width of every column and span, with an overlay to check it and CSS to copy.

Column width–
Content width–
SpanWidth% of content

Layout Grids Explained: 12-Column Grids, Gutters, Margins and Breakpoints

Grids are the invisible structure behind organised layouts. Swiss designers formalised them in print in the 1950s and 1960s; Josef Müller-Brockmann’s book Grid Systems in Graphic Design (1981) became a classic reference. On the web, frameworks like the 960 Grid System and Bootstrap made the 12-column grid the default. Understanding how column grids work makes layouts faster to design and easier to build.

Twelve-column layout grid with gutters and margins over a web page

The parts of a column grid

PartWhat it is
ContainerThe total width the grid occupies
MarginsSpace between the container edge and the first and last column
ColumnsEqual-width vertical areas where content sits
GuttersFixed gaps between columns

Content spans one or more columns. A card might span 4 of 12 columns, a sidebar 3, an article 8.

Why 12 columns

12 divides evenly by 1, 2, 3, 4, 6 and 12. That allows halves, thirds, quarters and sixths without fractions:

LayoutColumn spans
Full width12
Two equal columns6 + 6
Three equal columns4 + 4 + 4
Four equal columns3 + 3 + 3 + 3
Main + sidebar8 + 4 or 9 + 3
Centered article8 columns, offset by 2

A 10-column grid can’t do thirds; a 16-column grid can’t do thirds either. That flexibility is why 12 became the web default.

Calculating column width

The formula:

Column width = (container − 2 × margin − gutter × (columns − 1)) ÷ columns

Example: a 1200px container, 12 columns, 24px gutters, 24px outer margins.

  • Content width: 1200 − 48 = 1152px
  • Total gutters: 24 × 11 = 264px
  • Column width: (1152 − 264) ÷ 12 = 74px

A span of n columns is n × column width + (n − 1) × gutter. A 4-column card here is 4 × 74 + 3 × 24 = 368px. The layout grid calculator above generates every span width and the matching CSS.

Responsive grids

One grid doesn’t fit all screens. A common setup:

BreakpointColumnsGutterMargin
Phone (under 600px)416px16px
Tablet (600–1024px)824px24–32px
Desktop (over 1024px)1224–32pxauto (centered container)

Material Design uses a similar 4/8/12 column system. Content that spans 12 columns on desktop might span 8 on tablet and 4 on mobile, keeping proportions consistent as the layout simplifies.

Many sites also cap the container width (1200–1440px) so that line lengths and card sizes don’t grow endlessly on very wide monitors.

Fluid versus fixed grids

TypeColumnsGuttersBehaviour
FixedFixed pxFixed pxSame layout at all widths above a breakpoint
FluidPercentage / frFixed pxColumns stretch; gutters stay the same
HybridFluid up to a max-widthFixed pxMost common today

CSS Grid makes fluid grids easy: grid-template-columns: repeat(12, 1fr) with column-gap: 24px creates 12 flexible columns with fixed gutters, and the browser does the math.

Grids in CSS

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; }
.card { grid-column: span 4; }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(8, 1fr); } }
@media (max-width: 600px)  { .grid { grid-template-columns: repeat(4, 1fr); column-gap: 16px; } .card { grid-column: span 4; } }

You don’t always need a 12-column system in code. For a card gallery, repeat(auto-fit, minmax(260px, 1fr)) is simpler. The 12-column grid is most useful for complex page layouts and for keeping design and code aligned. Our CSS Grid guide covers the techniques.

Gutters and the spacing system

Choose gutters and margins from your spacing scale (16, 24, 32px on an 8pt grid). Then everything, from component padding to column gaps, shares one rhythm. We cover spacing scales in the 8pt grid guide.

Grid habits that cause trouble

  • Treating the grid as a cage. Grids guide alignment; not every element must fill whole columns. Breaking the grid deliberately, for a full-bleed image or an overlapping element, creates emphasis.
  • Different gutters everywhere. Inconsistent gutters destroy the visual rhythm the grid is supposed to create.
  • Ignoring the vertical rhythm. Columns align horizontally; consistent vertical spacing and line heights complete the system.
  • Over-complex grids for simple pages. A blog article may only need a single centered column with a comfortable line length.

Grids in print

Print grids often add rows (modular grids) and a baseline grid to which all text aligns, so lines in neighbouring columns sit on the same baselines. Magazines and newspapers rely on these. On the web, baseline grids are harder to enforce exactly, but setting line heights and spacing to multiples of 4px gets close.