CSS Grid Generator
Draw a CSS grid layout visually. Size columns and rows, drag across cells to name areas, and copy CSS, HTML or Tailwind.
Live preview
3 columns × 3 rowsDrag across empty cells to add an area. Click a covered cell to select its area.
.grid {
display: grid;
grid-template-columns: 200px 1fr 200px;
grid-template-rows: auto 1fr auto;
grid-template-areas: "header header header"
"nav main aside"
"footer footer footer";
gap: 16px;
}
.header {
grid-area: header;
}
.nav {
grid-area: nav;
}
.main {
grid-area: main;
}
.aside {
grid-area: aside;
}
.footer {
grid-area: footer;
}Everything stays in your browser.
How to use
- Start from a layout template, or choose Blank and set your own columns and rows.
- Edit each track size, then drag across the preview cells to add a named area. Click an area’s cell or its chip to select it.
- Rename the area or adjust its lines and gaps, then export CSS, HTML or Tailwind.
Example
grid-template-areas: "header header header" "nav main aside" "footer footer footer";
Details and limitations
Track sizes accept px, rem, em, %, vh, vw, ch, fr, auto, min-content, max-content, minmax() and fit-content(). Identical tracks are written as repeat().
Named areas are exported with grid-template-areas when no two areas share a cell. If areas overlap, every area is placed with grid-row and grid-column line numbers instead.
Area names are lowercased and other characters become hyphens. Up to 12 columns, 12 rows and 16 areas are supported.
The preview is 380 px tall, so fr rows share that height. With the keyboard, press Enter on one cell and then on another to draw an area; Escape cancels.
FAQ
When should I use CSS Grid instead of Flexbox?
Grid controls rows and columns at the same time, so it suits page layouts, dashboards and galleries where items line up in both directions. Flexbox arranges items along one axis and is simpler for toolbars, navigation and centering.
What does 1fr mean?
fr is a share of the free space left after fixed tracks and gaps. In 200px 1fr 2fr, the last two columns split the remaining width one third and two thirds.
Why does the export use line numbers instead of area names?
grid-template-areas can only describe rectangles that do not overlap. When two areas share a cell, the generator positions every area with grid-row and grid-column so the overlap is kept.
Related tools
Format references
Tool page updated: