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.
1. Grid
.grid-containergrid-template-columns:
grid-template-rows:
2. Live preview
Dashed lines = tracks3. Items
Up to 24 · source order matters for auto-placementGenerated code
Same CSS as the previewItem 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 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.
Step by step
- Set the number of columns and rows.
- Enter a size for each column and row track.
- Adjust gaps, width, height, padding and alignment.
- Place items by choosing column and row start and end lines, or leave them on auto.
- Add, remove or reorder items and check the live preview.
- Copy or download the CSS and HTML.
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
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.
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.
Common questions
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.