CSS Layout Generator

Generate page layouts — holy grail, sticky footer, sidebar — plus multi-column text and media-query breakpoints, using modern Grid rather than old hacks.

Mobile-first and desktop-first are not mirror images

The two strategies produce the same number of regimes from the same breakpoints — n breakpoints give n+1 regimes either way — so it looks like a pure matter of taste. It isn't. We simulated every query this page generates against every viewport width and only one of them covers the width axis exactly once.

The cause is that both min-width and max-width are inclusive. A viewport of exactly 768px matches min-width: 768px and also matches max-width: 768px, so writing both at the same number overlaps rather than divides. The standard fix, which this page uses, is to subtract a sliver and emit max-width: 767.98px. That removes the overlap — but the gap is now exactly the thing you subtracted, and no value makes it zero. That would need an exclusive bound, and media queries of this form don't have one.

ViewportDesktop-first gives itIt should get
767.99px (Bootstrap set)the below lg rulesbelow md
991.99pxthe below xl rulesbelow lg
1399.99pxno query matches — the base desktop rulesbelow xxl

That last row is the worst case: the topmost sliver of every set falls past every override and lands on the unqualified base styles, which in a desktop-first sheet are your widest layout. Across the three sets here that's 12 slivers — one per breakpoint, 2 in the simple set and 5 each in Bootstrap and Tailwind. The mobile-first output has none, anywhere: min-width alone tiles the axis exactly.

To be straight about the size of this: 0.02px is not reachable at an ordinary integer window width. You need a fractional viewport, which comes from browser zoom and from some fractional-scaling displays. So it's a real defect that's rarely hit — and still the reason mobile-first is the better default, because it's exactly right rather than nearly right, and it costs nothing.

One incidental find: the three breakpoint sets here were designed independently and agree on exactly one number. 768px is in all three, and both Bootstrap and Tailwind call it md. 1024px appears in two. Nothing else appears more than once.

On the columns tab, the count is a ceiling

The multi-column output is columns: {n} 180px — the shorthand takes a count and a minimum width, and when both are given the count is a maximum rather than a target. The browser fits as many 180px columns as the container allows, up to that number. So the slider is really asking "at most how many," and what you get depends on how wide the container is:

ColumnsContainer needed (at the 28px default gap)What a 900px container gives
2 388px 2
3 596px 3
4 804px 4
5 1012px 4 — fewer than asked
6 1220px 4 — fewer than asked

Each extra column costs one column plus one gap, so the steps are identical — 208px every time. In a 900px container, asking for 4, 5 or 6 all give you 4. At a 768px page width you can get 3 at most, and on a 375px phone you get one whatever the slider says. That last part is the point of writing the shorthand this way instead of as a bare count: the layout degrades on its own without needing a media query.

How to use

  1. Pick a layout pattern.
  2. Set the sidebar widths and gaps.
  3. Check the responsive behaviour.
  4. Copy the generated HTML and CSS.

Frequently asked questions

What is the holy grail layout?

A header, a footer, a fluid centre column and two fixed sidebars, with the centre appearing first in the source. It earned the name because it was genuinely difficult before Grid — requiring negative margins and careful float ordering — and now takes a handful of lines.

How do I keep a footer at the bottom of a short page?

Make the body a grid with the main content set to take the remaining space, and give the whole thing a minimum height of the viewport. The footer then sits at the bottom on short pages and below the content on long ones, with no absolute positioning involved.

What breakpoints should I use?

Whatever your content needs, rather than a list of device widths. Widen the window until the layout looks wrong, and put a breakpoint there. Designing against specific devices dates immediately and produces layouts that break on anything unusual.

Should I design mobile first?

Generally yes. Starting narrow and adding complexity at wider widths produces simpler CSS, since min-width queries add rather than override. It also forces the content hierarchy to be decided early, which tends to improve the wide layout as well.

Why does the source order matter if Grid can rearrange things?

Because screen readers and keyboard navigation follow the source, not the visual arrangement. A layout that looks correct while reading in a nonsensical order is a genuine accessibility failure, so visual reordering should stay close to the logical order.

Are CSS multi-column layouts useful for the web?

Rarely for long text. Columns require the reader to scroll down and back up for each one, which is fine on paper and awkward on screen. They suit short lists and card-like content where each column is read independently.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.