Home: Mohammad Abu-aishehOpen to work Open to work العربية

UI & visual design // Guide

Layout grids: columns, gutters, margins

A grid brings order to layouts. Learn columns, gutters and margins, content-led breakpoints, comfortable line length and CSS grid basics.

Layout grids: columns, gutters, margins

The parts of a grid

A layout grid has three parts. Columns hold content. Gutters are the gaps between columns. Margins are the space between the grid and the screen edge. Together they give every element a predictable place, which makes pages feel aligned and easier to scan.

  • Common conventions: 4 columns on phones, 8 on tablets, 12 on desktop.
  • Gutters and margins work well when taken from the spacing scale.

Breakpoints, line length and margins

Set breakpoints where the content breaks, not at the sizes of particular devices. Narrow the browser window until the layout looks wrong, then add a breakpoint at that width. Device sizes change every year; content problems do not.

Also set a maximum content width. A long-standing typographic guideline is roughly 45 to 75 characters per line for comfortable reading. Wider lines make it hard to find the start of the next line.

<code>max-width: 65ch;</code> is a quick way to limit text width.

Margins and gutters scale with the screen. A phone may use a 16 px margin and a 16 px gutter, while a desktop layout might use a 24 or 32 px gutter inside a centred container with a maximum width. Taking these values from the spacing scale keeps the grid in step with the rest of the interface.

  • Not every element must span many columns. A narrow article column surrounded by empty columns is a valid layout.
  • Let images and cards span whole columns so their edges line up.
  • Test the layout with real content, including long words and longer Arabic text.

CSS grid in practice

CSS grid builds these layouts directly. A responsive card grid needs no media queries:

Example: <code>display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));</code>

Each column is at least 240 px wide, and the browser fits as many as the space allows.

Keep alignment consistent

  1. Choose a column count and take gutters from the spacing scale.
  2. Align elements to column edges, not to arbitrary positions.
  3. Cap text width near 65 characters.
  4. Find breakpoints by resizing the content.

For right-to-left layouts, use logical properties so the grid mirrors correctly.

Consistent alignment is the quiet benefit of a grid. When headings, images and buttons share the same left edge, or the same right edge in Arabic layouts, the page reads as one organised surface. Break the grid only on purpose, for example for a full-width image, and make the exception obvious.

Sources

  • MDN Web Docs. CSS grid layout. https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout

This guide was drafted with AI assistance from public standards and references. For the exact wording of a standard, use the sources listed above.

More on this topic

  • UI & visual design2 min read

    Designing dark mode properly

    Dark mode is not an inversion. Learn soft surfaces, off-white text, elevation by lightness, adjusted accents and how to honour user settings.

  • UI & visual design2 min read

    Designing useful empty states

    An empty screen is a chance to guide people. Learn the four kinds of empty state, what each should say, and how to avoid dead ends.

  • UI & visual design2 min read

    Icon design principles

    Icons save space but can confuse. Learn when to add labels, how to keep a consistent grid, and how to make icon buttons accessible.

Keyboard shortcuts
Single-key shortcuts

Turn off if you use speech input or find them getting in the way.