X Xerobit

CSS Grid Generator

Visual builder for CSS Grid layouts. Define columns and rows with any valid grid-template-* syntax. Presets for common patterns (12-col grid, sidebar+content, auto-fill).

Live preview
CSS output
 

How to use the CSS grid generator

Getting from a blank grid to production-ready CSS takes four steps:

  1. Set the number of columns (grid-template-columns) — Enter a value like repeat(3, 1fr) for three equal columns, or 200px 1fr 200px for a sidebar-main-sidebar layout. Every valid CSS value works.
  2. Set the number of rows (grid-template-rows) — Define fixed row heights (100px 200px), auto-sizing rows (auto), or leave it blank to let the grid create implicit rows as needed.
  3. Adjust the gap between cells (gap / column-gap / row-gap) — Enter a single value for uniform gutters (1rem) or separate values for column and row gaps (1rem 2rem).
  4. Copy the generated CSS and paste into your stylesheet — The output panel updates live. Click Copy to grab the full .container ruleset and drop it straight into your project.

CSS Grid cheat sheet

Quick reference for the properties you'll reach for most often:

Property What it does Example
grid-template-columns Defines column sizes 1fr 1fr 1fr or repeat(3, 1fr)
grid-template-rows Defines row sizes 200px auto 100px
gap Space between cells 16px or 1rem
grid-column Span columns for an item 1 / 3 (span columns 1–2)
grid-row Span rows for an item 1 / -1 (span all rows)
grid-area Named area placement header
justify-items Align items horizontally start / center / end / stretch
align-items Align items vertically start / center / end / stretch

Grid template values cheatsheet

CSS Grid vs Flexbox — when to use each

Both Grid and Flexbox are layout tools, but they solve different problems:

For a deeper comparison, see CSS Grid vs Flexbox — choosing the right layout model.

Common grid layout patterns

Copy any of these directly into your stylesheet or paste them into the generator above to preview visually.

12-column grid (Bootstrap-like)

/* 12-column grid */
.container {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

Holy grail layout

Header spanning full width, a left sidebar, main content area, right aside, and a full-width footer — all without floats or hacks. See also: building responsive grid layouts.

/* Holy grail: header, sidebar, main, aside, footer */
.container {
  display: grid;
  grid-template-areas:
    "header header header"
    "sidebar main aside"
    "footer footer footer";
  grid-template-columns: 200px 1fr 200px;
}

Responsive auto-fill card grid

No media queries needed. Columns wrap automatically when the viewport narrows. For a full walkthrough see CSS Grid areas guide.

/* Responsive card grid — no media queries */
.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

CSS Grid browser support

CSS Grid reached 98%+ global browser support in 2017 across Chrome, Firefox, Safari, and Edge. It is safe to use in production without any fallbacks.

Subgrid (grid-template-columns: subgrid) — which lets nested grids inherit the parent's track definitions — crossed the 90% support threshold in 2023 after Safari and Firefox shipped it. Chrome added support in version 117. You can use subgrid in new projects today, though a simple fallback (display: contents) covers the remaining gap.

Frequently asked questions

What is the fr unit in CSS Grid?

fr stands for fractional unit. It represents a share of the available space in the grid container after fixed-size and auto-size tracks have been allocated. Writing grid-template-columns: 1fr 1fr 1fr divides the container into three equal columns. Writing 200px 1fr 2fr reserves 200px for the first column, then splits the remainder into thirds — one third for the second column and two thirds for the third.

Can I use CSS Grid for responsive design without media queries?

Yes. The pattern repeat(auto-fill, minmax(250px, 1fr)) creates a grid that automatically adds or removes columns based on the available width. Each column is at least 250px wide and expands to fill extra space. No breakpoints, no @media rules — the browser handles it. This is one of the most practical advantages of CSS Grid over older layout techniques.

What's the difference between grid-gap and gap?

grid-gap was the original property name from the early CSS Grid specification. It was renamed to gap when the spec was updated to apply the same property to both Grid and Flexbox layouts. Both names work in all modern browsers, but gap is the current standard and the one you should use in new code. Linters and style guides (including Stylelint's recommended config) will flag grid-gap as deprecated.

Related tools

Related articles

Pillar

Part of Frontend & Design.


Written by Mian Ali Khalid. Last updated 2026-05-12.