1. Home
  2. Design tools
  3. CSS Grid Generator

CSS Grid Generator

Define your columns and rows, place items by line numbers and spans, and copy clean grid CSS with matching HTML.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use CSS Grid Generator

  1. Set the number of columns and rows and their sizes.
  2. Select an item and set where it starts and how far it spans.
  3. Copy the CSS and HTML.

Features

  • Up to 8 columns and rows with fr, px, %, auto, minmax()
  • Row and column gaps
  • Items placed by start line and span
  • Equal tracks collapse into repeat()
  • Warnings for items outside the grid
  • A dashboard-style sample

Supported formats

Input

  • Track sizes and item positions

You get

  • CSS
  • HTML

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the CSS Grid Generator is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Named grid areas, auto-fit and subgrid are not generated.
  • Items are placed by line numbers; overlapping items are allowed and not flagged.

Guide

Laying out a page with CSS Grid, line by line

CSS Grid is the layout system for two-dimensional designs: you describe columns and rows, then put items into the cells they should occupy. It replaces a lot of nested boxes and clearing tricks, but its vocabulary of tracks, lines and spans takes time to learn. This builder lets you shape a grid on screen and copy the CSS and HTML, so you can see how each number moves the boxes.

Tracks and lines

A grid has columns and rows, collectively tracks, and invisible lines between them. A grid with three columns has four vertical lines, numbered from 1 at the left edge, and a grid with two rows has three horizontal lines, numbered from 1 at the top. Track sizes are written in a list: 200px 1fr 1fr means a fixed first column and two columns that share what remains. The unit fr stands for a fraction of the free space after fixed tracks and gaps are subtracted.

A worked example

Press Sample to load a page layout. The columns are 200px 1fr 1fr, the rows are auto 1fr auto, and both gaps are 16 pixels. The page writes display: grid;, grid-template-columns: 200px 1fr 1fr;, grid-template-rows: auto 1fr auto; and gap: 16px;. The four items are the header, the sidebar, the main area and the footer. The header is grid-column: 1 / span 3; on row 1, which starts at line 1 and covers all three columns. The sidebar is column 1 of row 2, the main area is grid-column: 2 / span 2; on row 2, and the footer spans three columns again on row 3. The middle row, written 1fr, takes all the height the header and footer do not need.

Controlling tracks

Type a track size into each field; a field with an invalid size such as 10 turns red and the page lists the problem. auto fits the content, min-content and max-content use the smallest and largest content width, and minmax(100px, 1fr) sets a floor under a flexible track. When every track in a list is the same, the page writes repeat(3, 1fr) instead of 1fr 1fr 1fr, which is shorter and easier to change. Equal gaps collapse to one gap value; different row and column gaps are written as gap: row column.

Placing items

Select an item with the numbered buttons, then set its starting column, how many columns it spans, its starting row and its row span. The preview and the CSS update together. Items that reach past the last track, such as a span of three starting at column 3 in a three-column grid, are flagged. Use the add and remove buttons to change how many items there are. Each item gets a class such as item-1 in the CSS, and the HTML block shows the matching markup.

Edge cases

Items that you leave out of explicit placement are positioned automatically by the browser, so only place the ones that need a specific cell. Overlapping is allowed in grid and is useful for layering text over an image, but this page does not block it, so check the preview. Rows set to 1fr only stretch when the container has a height. Very long content can push auto tracks wider than expected; add min-width: 0 to grid children that hold long words or code.

Limits

The builder writes line-based placement and does not generate named areas, auto-fit or subgrid. It is a learning and prototyping tool: the HTML is minimal and the classes are placeholders. Everything is computed in your browser.

Checked against the current version of the CSS Grid Generator on .

Troubleshooting

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why do my items not stay where I put them on a phone?

A fixed number of columns that is comfortable on a desktop can be too wide on a narrow screen. Wrap the layout in a media query that switches to one column, or use repeat(auto-fit, minmax(200px, 1fr)) for automatic wrapping.

What is the difference between gap and margin?

gap adds space only between tracks and never at the outer edges, so it spaces items evenly without extra rules for the first and last. Margins on items add to the gap and move with the item.

What does 1fr mean?

One fraction of the free space left after fixed-size tracks and gaps are taken out. Two columns of 1fr and 2fr share the space one to two.

How are grid lines numbered?

From 1, starting at the left edge for columns and the top edge for rows. An item with grid-column: 2 / span 2 starts at line 2 and covers two columns.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.