CSS Grid Generator

Build CSS Grid layouts visually: columns, rows, gaps, named areas and item spans, with live preview and CSS and HTML.

Runs in your browser. Nothing is uploaded.

Presets
Grid container

Preview click an item to place it · drag the corner to resize
Item 1

How to use the CSS Grid Generator

  1. Type the columns, for example repeat(3, 1fr) or 200px 1fr, and optionally the rows.
  2. Set the gaps, the alignment of items and how many items the grid holds.
  3. To name areas, type one row per line in grid-template-areas, such as header header then sidebar main.
  4. Click an item to place it with grid-column, grid-row or an area name.
  5. Start from a preset, then copy the CSS and HTML.

Two-dimensional layouts, visually

CSS Grid lays out content in rows and columns at the same time. It is the right tool for page layouts with a header, sidebar and footer, for photo galleries and card grids, and for dashboards where boxes of different sizes need to line up. Its syntax is powerful but dense: track sizes, fr units, repeat(), minmax(), named areas and line numbers. This generator lets you change each part and see the layout update immediately.

Define the grid

  • Columns and rows accept any CSS track list: fixed sizes like 200px, flexible fr units, auto, minmax() and repeat(). If the browser doesn’t understand a value, you get a warning straight away.
  • Gaps set the space between columns and rows separately.
  • justify-items and align-items place items inside their cells.
  • grid-template-areas gives names to regions of the grid, so CSS reads like a map of the page.

Place the items

Click an item in the preview to select it. Give it a column or row placement, such as span 2 to make it wider or 1 / -1 to stretch across the whole row, or assign it a named area like header. Items without a placement flow into the next free cells.

Presets for common layouts

  • Three equal columns: the classic grid of equal cards.
  • Responsive cards: auto-fill with minmax(), which wraps on its own with no media queries.
  • Page layout: header, sidebar, main and footer with named areas.
  • Feature + grid: one large tile spanning two columns and two rows beside smaller ones.

Copy CSS and HTML

The output shows the container CSS, any item placements, and matching HTML. Drag the preview’s corner to check how the layout behaves as the width changes. For single rows or columns of items, the Flexbox Playground is often simpler. Everything runs in your browser.

Frequently asked questions

What does fr mean?

fr is a fraction of the free space. 1fr 2fr gives the second column twice the space of the first after fixed sizes and gaps are taken out.

How do I make a responsive grid without media queries?

Use repeat(auto-fill, minmax(160px, 1fr)). The browser fits as many 160-pixel-wide columns as possible and stretches them to fill the row, so the grid wraps naturally on small screens.

Why is my area layout rejected?

Every row must have the same number of cells, and each named area must form a rectangle. Use a dot (.) for an empty cell.

What does span 2 mean?

grid-column: span 2 makes an item two columns wide from wherever it lands. 1 / 3 instead places it from line 1 to line 3, which is also two columns, but at a fixed position.

Is anything uploaded?

No. Everything runs in your browser.

Tutorials