CSS Grid

CSS Grid Generator

Set up columns and rows, size each track, and place items by grid line. Overlapping or out-of-range placements are refused with an explanation, and dashed lines show exactly where the tracks are.

Back

1. Grid

.grid-container

grid-template-columns:

grid-template-rows:

2. Live preview

Dashed lines = tracks

3. Items

Up to 24 · source order matters for auto-placement

Generated code

Same CSS as the preview

Item colours, padding and fonts in the preview are demo styling only — they are not part of the CSS above. Download HTML gives a standalone page with the CSS and the demo styling in separate blocks.

About this tool

About CSS Grid Generator

CSS Grid Generator helps you design two-dimensional layouts. You choose the number of columns and rows, size each track (fr, px, %, auto, minmax() and more), set gaps, size, padding and alignment, and place items by their start and end grid lines with justify-self and align-self. Dashed lines show where the tracks really are, and invalid or overlapping placements are refused with an explanation.

Grid layouts are powerful but hard to picture from code alone. Seeing the tracks and placements while you edit makes it easy to build page layouts, dashboards and card grids correctly, and the generated CSS can be pasted straight into a project.

How to use

Step by step

  1. Set the number of columns and rows.
  2. Enter a size for each column and row track.
  3. Adjust gaps, width, height, padding and alignment.
  4. Place items by choosing column and row start and end lines, or leave them on auto.
  5. Add, remove or reorder items and check the live preview.
  6. Copy or download the CSS and HTML.
Key features

What it offers

  • Up to 12 columns and 12 rows
  • Track sizes with fr, lengths, auto, min/max-content, minmax() and fit-content()
  • Automatic repeat() for equal tracks
  • Gap, row-gap and column-gap
  • justify/align items and content
  • Per-item start and end lines, justify-self and align-self
  • Overlap and out-of-range placement checks
  • Visible track lines, including shaded implicit tracks
Best practices

Tips for best results

  • Use fr units for flexible columns and minmax() to set sensible minimum sizes.
  • Place large items explicitly and let smaller ones auto-place.
  • Keep the source order logical for screen readers, even if items are placed elsewhere visually.
  • Watch for shaded implicit rows — they mean items didn’t fit the grid you defined.
  • Test the layout at different widths and add media queries where needed.
Benefits

Why people use it

Visual

See the grid lines and placements as you edit.

Safe edits

Invalid and overlapping placements are blocked.

Accurate code

The preview uses exactly the CSS you copy.

Local

Runs entirely in your browser.

FAQ

Common questions

Lengths (px, %, em, rem, vw, vh, ch), fr units, auto, min-content, max-content, minmax(min, max) and fit-content(length). Equal tracks are written as repeat(), for example repeat(3, 1fr).
Grid lines are numbered from 1 at the left (or top). An item with column start 1 and end 3 spans the first two columns. Leave start on auto to let the browser place the item in the next free cell.
The tool blocks placements that start outside the grid, end before they start, or overlap another explicitly placed item. The message says which item and cell caused the problem; nothing is changed until it is valid.
When auto-placed items don’t fit the rows and columns you defined, the browser creates extra rows automatically (the implicit grid). Those tracks are shaded so you can see them.
Yes. The CSS below is applied to the preview, and the dashed lines are drawn from the track sizes the browser actually calculated.
Alignment values set to normal and sizes set to auto are browser defaults, so they are left out to keep the CSS short.
Yes. All current major browsers support the grid properties used here, including gap and minmax().
Private by design

This runs entirely in your browser

No file or text you enter here is uploaded. Encoding and decoding happen on your device using native browser APIs — close the tab and nothing remains on a server.

Install Toolisco Add it to your device for offline, one-tap access.