CSS Grid Generator
Design CSS grid layouts visually and copy the CSS
Cells are numbered in reading order; gaps update live as you drag.
Named areas replace the column/row sliders with a preset region layout.
How to Use
- Set the grid dimensions — Drag the column and row sliders to choose between 1 and 12 tracks each; the numbered preview cells update instantly.
- Adjust the gaps — Use the column-gap and row-gap sliders to control spacing between tracks without writing margin rules.
- Enable named areas (optional) — Toggle named areas and pick a preset layout — Holy Grail, Sidebar, or Cards — to see a region-based grid drawn as a text diagram.
- Copy the CSS — Grab the generated
.containerblock (plus one.area-namerule per region when named areas are on) and paste it into your stylesheet.
Features
- Full track control — 1–12 columns and rows with independent column-gap and row-gap sliders, all synced between range and number inputs.
- Live preview — Every change renders immediately on a demo grid with numbered, color-coded cells.
- Named-area presets — One-click Holy Grail, Sidebar, and Cards layouts that emit a readable grid-template-areas diagram plus matching grid-area rules.
- Clean output — Zero gaps are elided and track counts use repeat() shorthand, so you copy only what matters.
- 100% client-side — Everything runs in your browser; no data ever leaves your device.
Use Cases
- Page skeletons: Prototype a header/sidebar/main/footer structure with the Holy Grail preset, then swap the fr tracks for fixed side widths in your own code.
- Card galleries: Dial in the column count and gaps for a responsive product grid and verify the wrapping behavior before writing media queries.
- Learning CSS Grid: Flip between plain tracks and named areas to build intuition for how grid-template-columns, grid-template-rows, and grid-template-areas interact.
Related Tools
- CSS Flexbox Generator — Design one-dimensional flexbox layouts with live preview.
- CSS Box Shadow Generator — Design layered box shadows with live preview.
- CSS Gradient Generator — Build custom CSS gradients for your layouts.
Frequently Asked Questions
What is the difference between CSS Grid and Flexbox?
Flexbox lays items out along a single axis — a row or a column — which makes it ideal for navbars and one-dimensional flows. CSS Grid works in two dimensions at once, letting you define rows and columns simultaneously, so it is the better tool for full page layouts and card galleries where items must align both horizontally and vertically.
What does repeat(3, 1fr) mean?
It is shorthand for defining three columns that each take one equal fraction of the available space. The fr unit distributes leftover space proportionally, so repeat(3, 1fr) is equivalent to writing 1fr 1fr 1fr — three flexible, equal-width tracks that grow and shrink together.
When should I use grid-template-areas?
Named areas shine when your layout has recognizable regions like header, sidebar, main, and footer. Instead of placing items with line numbers, you draw the layout as a text diagram in grid-template-areas and assign each element a grid-area name. Restructuring the layout later means editing the diagram, not hunting down placement rules.
What is the difference between column-gap and row-gap?
column-gap sets the spacing between grid columns (vertical gutters), while row-gap sets the spacing between rows (horizontal gutters). You can also use the gap shorthand to set both at once, but separate properties give you independent control — for example, tight column spacing with generous row spacing.
Is the generated CSS ready for production?
Yes. The output uses standard, widely-supported grid properties that work in every modern browser. Default values like zero gaps are omitted so the CSS stays clean — paste it into your stylesheet and adjust track sizes (for example swapping 1fr for fixed pixels) as needed.