CSS Grid generator
This tool builds a CSS Grid container visually and gives you the display: grid rules to paste into your stylesheet. It is for developers who want a quick column/row layout without memorising grid-template syntax. Set the track count, choose the sizing unit, tune the gaps, and copy.
How it works
The generator writes a display: grid block with grid-template-columns and grid-template-rows built from repeat(count, size). The sizing unit you pick decides the track size: fr uses 1fr (each track shares leftover space equally), px uses fixed sizes (120px columns, 80px rows), and auto sizes each track to its content. The gap is written as two values — row gap first, then column gap — matching the CSS gap: <row> <column> shorthand. The preview is a real grid using the same template, filled with numbered cells.
Example
With 3 columns, 2 rows, row gap 12px, column gap 12px and the fr unit, the tool outputs:
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 12px 12px;
This makes a 3×2 grid of equal cells with 12px spacing in both directions.
| Unit | grid-template-columns (3 cols) | Behaviour |
|---|---|---|
| fr | repeat(3, 1fr) | Equal, fills the container |
| px | repeat(3, 120px) | Fixed 120px columns |
| auto | repeat(3, auto) | Each column fits its content |
Everything runs in your browser — nothing is uploaded.