cssgridgen

Responsive CSS Grid Generator

Draw the layout at each width. Copy CSS with the media queries already written.

Open in
1180px

Drag across the grid to draw an area. Arrow keys nudge, Shift + arrows resize.

space to pan · ⌘scroll to zoom
1220px21fr3
1auto21fr3auto4
header1 / 1 / 2 / 3
main2 / 2 / 3 / 3
footer3 / 1 / 4 / 3
nav2 / 1 / 3 / 2

Named areas. The CSS is a picture of the layout, and only the properties that actually change get repeated inside each media query.

.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  grid-template-areas:
    "header"
    "main"
    "footer";
}

.layout > .header { grid-area: header; }
.layout > .main { grid-area: main; }
.layout > .footer { grid-area: footer; }
.layout > .nav { display: none; }

@media (min-width: 768px) {
  .layout {
    grid-template-columns: 220px 1fr;
    grid-template-areas:
      "header header"
      "nav    main"
      "footer footer";
  }

    .layout > .nav { grid-area: nav; }
}

The problem with every other grid generator

One layout is never enough

Most CSS grid generators hand you a single static grid. Real layouts change shape as the viewport does. Here you drag the ruler above to any width, redraw the grid for that width, and the export carries every breakpoint with it — mobile-first, and only repeating the properties that actually change.

It works as a plain grid generator too: set the columns and rows, drag out the areas, and take the code. Whether you think of it as a CSS grid layout generator, a grid builder, or a grid-template-areas generator, it is the same three steps — and unlike a snippet you copy off a blog, what comes out is scoped to a class name you choose and already handles the widths you care about.

Start from a layout pattern

Every pattern opens in the editor, already responsive. Change anything.

How to use it

  1. Set the preview width

    Drag the playhead along the ruler above the canvas. The canvas resizes to that exact width and the breakpoint it falls into becomes the one you are editing — the panel on the right always says which.

  2. Draw your areas

    Drag across the grid to create a named area. Each area becomes one child element in the exported HTML, and it exists at every breakpoint.

  3. Size the tracks

    Edit the column and row values in the Tracks panel. Anything valid in a track list works: fr, px, %, auto, min-content, minmax() and repeat().

  4. Redraw at the next breakpoint

    Move the playhead past a breakpoint marker and rearrange freely. Only the placement changes — the elements stay the same, which is what keeps the exported CSS correct.

  5. Copy the code

    Take CSS, HTML or Tailwind from the panel below. The media queries are already written, and only the properties that actually change are repeated.

How the breakpoint export works

The areas you draw are the same DOM elements at every width — only their placement changes. That is what makes the generated CSS correct: one block of HTML, one base rule, and a media query per breakpoint that overrides just the tracks and placements that differ.

Where your areas tile cleanly, the export uses grid-template-areas, so the CSS reads as a picture of the layout. Where they overlap — which named areas cannot express — it falls back to explicit grid-area line numbers and tells you why.

Named areas or line numbers?

Named areas are easier to read and change: rearranging a page means editing the ASCII map and nothing else. Line numbers win when items overlap, when tracks are generated with repeat(), or when placement is computed. The generator picks for you and shows its reasoning; the dropdown overrides it.

A note on source order

Grid will happily place an element anywhere, including somewhere that contradicts its position in the HTML. Keyboard and screen-reader users follow the DOM, not the visual grid, so a layout that reorders content between breakpoints needs a deliberate check that it still reads in a sensible sequence.

For the full property reference — every container and item property, and every track-size value with the reason to use it — see the CSS Grid cheat sheet.

Frequently asked questions

How do I center a grid in CSS?
Use justify-content: center on the grid container to centre the whole grid inside it, and margin-inline: auto with a max-width to centre the container in the page. These are different jobs: the first moves the tracks within the container, the second moves the container itself.
How do I center items inside a CSS grid?
Set place-items: center on the container. That is shorthand for align-items plus justify-items, and it centres every item inside its own cell on both axes. For a single item, use place-self: center on that item instead.
How do I make a CSS grid responsive?
Use grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) and it reflows at every width with no media queries at all. Add breakpoints only when the exact column count matters, or when the layout has to change shape rather than just wrap.
When should I use CSS Grid instead of Flexbox?
Use Grid when things must line up in two directions at once, and Flexbox when content flows along one axis. A page skeleton or dashboard is Grid; a navbar or row of buttons is Flexbox. They nest: Grid for the page, Flexbox inside the cells.
What is the fr unit in CSS Grid?
fr is a fraction of the space left over after fixed tracks and gaps are subtracted. In grid-template-columns: 200px 1fr 2fr, the 200px is taken out first, then the remainder splits three ways — one part to the second column, two to the third. It is not a percentage of the container.
Why does my grid item overflow its column?
Because 1fr means minmax(auto, 1fr), and that auto minimum refuses to shrink below the content — a wide image or long unbroken string pushes the track open. Use minmax(0, 1fr) instead.
What is the difference between grid-template-areas and grid-column?
Named areas describe the layout as a picture you can read; line numbers place items by coordinate. Areas are easier to rearrange but only work for non-overlapping rectangles with ident-safe names. This generator picks whichever applies and says which one it used.
Does CSS Grid break keyboard navigation?
It can, because Grid places items anywhere regardless of source order while keyboard focus and screen readers follow the DOM. If your visual order contradicts your HTML — especially if it changes between breakpoints — the tab sequence will jump around the page.