CSS Grid Generator

A free CSS grid builder that outputs grid-template-areas CSS — the approach professionals use, not just grid-column: span X. Paint named areas by clicking and dragging, set per-track column and row sizes independently, pick from real-world presets, then copy production-ready CSS. No signup required.

Presets:

Columns

Rows

Column gap

Row gap

Column sizes

Each column can have its own track size. Use fr for flexible, px for fixed, auto, or minmax().

All:

Row sizes

Set a size for each row. auto is ideal for header/footer rows that size to their content.

All:
How to paint an area: Click on any empty cell in the canvas, drag to another cell to define a rectangle, then release and name it. Click an existing area to select it.
No areas yet.
Click and drag on the canvas to create your first named area.

Name this area:

Letters, numbers, hyphens only. No spaces.

justify-items

Aligns all items along the inline (column) axis.

align-items

Aligns all items along the block (row) axis.

justify-content

Distributes the column tracks within the container.

align-content

Distributes the row tracks within the container.

place-items and place-content are shorthands: place-items: center sets both align-items and justify-items in one declaration.
Live Preview
× grid
Areas cannot overlap — try an empty region

Click and drag on the grid to paint named areas · Or pick a preset above

Container properties

display
grid | inline-grid
grid-template-columns
Track sizes for columns
grid-template-rows
Track sizes for rows
grid-template-areas
Named area map as quoted strings
gap / column-gap / row-gap
Space between tracks
justify-items / align-items
Align items within their cell
justify-content / align-content
Distribute tracks in container

Item properties

grid-area
Assign to a named area
grid-column
start / end (e.g. 1 / 3)
grid-row
start / end (e.g. 2 / 4)
justify-self
Override justify-items for one item
align-self
Override align-items for one item
place-self
Shorthand for align-self + justify-self

Track size values

1fr
One fraction of available space
auto
Size to content
200px
Fixed pixel size
minmax(200px, 1fr)
At least 200px, can grow
repeat(3, 1fr)
Three equal columns
repeat(auto-fill, minmax(240px, 1fr))
Responsive auto columns

Common patterns

Holy Grail
cols: 200px 1fr 160px; rows: auto 1fr auto
Sidebar layout
cols: 240px 1fr; rows: 1fr
Equal 3-col
cols: repeat(3, 1fr)
Responsive cards
repeat(auto-fill, minmax(240px, 1fr))
Perfect centering
place-items: center; min-height: 100vh

Frequently asked questions

CSS Grid is two-dimensional — it controls rows and columns simultaneously and is ideal for overall page structure (header, sidebar, main, footer). Flexbox is one-dimensional — it lays items out in a single row or column and excels at aligning content within components such as navigation bars, card footers, and button groups. Use them together: Grid for the page layout, Flexbox for the components inside it. Neither is better — they solve different problems.
1fr is the fractional unit — one fraction of the available space after all fixed-size and auto tracks are placed. If you have three columns set to 1fr 1fr 1fr, each gets one-third of the available container width. If you use 2fr 1fr, the first column gets twice the space of the second. The fr unit distributes remaining space — so 200px 1fr 1fr gives 200px to the first column and divides the rest equally between the other two.
grid-template-areas lets you name rectangular regions of your grid using a visual map. Each quoted string represents one row; names in the same position across adjacent rows span those rows. A dot (.) marks an empty cell. Example: "header header" "sidebar main" "footer footer" creates a 2-column, 3-row grid with a full-width header and footer, and a sidebar/main split in the middle. Then assign each element to its area with grid-area: header (no quotes). Every named area must form an exact rectangle — irregular shapes silently invalidate the entire declaration.
To center all items within their grid cells, set place-items: center on the container — this is shorthand for align-items: center; justify-items: center. To center the grid tracks themselves within the container (useful when the grid is smaller than its container), add place-content: center. For a single element perfectly centered in a full-viewport layout, use display: grid; place-items: center; min-height: 100vh on the wrapper — no additional item properties needed.
gap is shorthand for row-gap and column-gap together. Writing gap: 16px sets both to 16px. Writing gap: 16px 24px sets rows to 16px and columns to 24px. Use column-gap and row-gap independently when you want different values for the two axes — for example, a tighter row gap for cards and a wider column gap for readability. Note: gap applies only between tracks — it does not add space around the outer edges of the grid.
minmax(min, max) defines a track that is at least min and at most max in size. It is most powerful combined with auto-fill: grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) creates as many columns as fit at 240px each and stretches them to fill the remaining space. This is the standard responsive card grid pattern — no media queries needed. A single-value shorthand: minmax(0, 1fr) is equivalent to 1fr but ensures the track can shrink to zero, which prevents overflow in edge cases involving content with a natural min-width.
The four most common causes: (1) Area name mismatch — the grid-area value must exactly match the name in grid-template-areas, case-sensitive. (2) Non-rectangular area — CSS requires every named area to be a perfect rectangle; an L or T shape silently invalidates the entire grid-template-areas declaration. (3) Missing grid-area on the item — defining areas on the container alone does nothing; each child must also declare grid-area: name. (4) Alignment not stretching — if justify-items or align-items is not stretch (the default), items size to their content rather than filling the area.
Yes — CSS Grid is fully supported in every modern browser (Chrome, Firefox, Safari, Edge) without vendor prefixes. It has been Baseline available since 2017. grid-template-areas has been universally supported since 2017 as well. You do not need a polyfill or fallback for any actively supported browser. Internet Explorer 11 had a partial, older implementation (-ms-grid), but IE11 reached end-of-life in 2022 and is not a concern for new projects.