Free tool CSS Grid generator: draw areas, copy the layout
Set your columns and rows, size each track, then drag across cells to mark a header, sidebar or card. The preview below runs the exact CSS and HTML you copy.
- Drag to create areas
- Works on touch screens
- Runs locally
Draw the grid, copy the code
The sample is a header, sidebar, main area and footer. Drag on empty cells to add an area; tap an area to edit it.
Saved to My tools
Open the free tools page next time and it is right at the top under My tools (stored in this browser only).
You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
View My toolsDraw areas
Drag across empty cells to make an area (a tap makes a one-cell area). Tap an area to select it. Keyboard: press Enter on the first cell, then on the last. This sketch shows equal columns; real sizes are in the preview.
Live preview (the code below)
Layout presets
Columns 3
Rows 3
Track sizes: 1fr, 200px, 25%, auto, min-content, minmax(120px, 1fr).
Output style
Areas
No areas yet: every cell gets one item in source order.
/* Layout */
.grid {
display: grid;
grid-template-columns: 160px repeat(2, 1fr);
grid-template-rows: 64px 1fr 56px;
grid-template-areas:
"header header header"
"sidebar main main"
"footer footer footer";
gap: 12px;
height: 340px;
}
.header {
grid-area: header;
}
.sidebar {
grid-area: sidebar;
}
.main {
grid-area: main;
}
.footer {
grid-area: footer;
}
/* Demo look: delete or replace with your own styles */
.grid {
box-sizing: border-box;
padding: 12px;
background-color: #eef2ff;
font-family: system-ui, sans-serif;
}
.grid > div {
box-sizing: border-box;
overflow: hidden;
padding: 10px 12px;
border-radius: 8px;
background-color: #4f46e5;
color: #ffffff;
font-size: 14px;
font-weight: 600;
}<div class="grid">
<div class="header">header</div>
<div class="sidebar">sidebar</div>
<div class="main">main</div>
<div class="footer">footer</div>
</div>Share these inputs: the values go after the # in the link, so they never reach a server.
https://tapcub.com/tools/css-grid-generator
Done here? Try these next
Use this tool often? Save it to My tools.Saved to My tools. Find it any time at the top of the free tools page. You can also press Ctrl+D to bookmark this page in your browser.You can also press ⌘+D to bookmark this page in your browser.You can also tap your browser’s Share button (at the bottom in Safari) and choose Add Bookmark or Add to Home Screen.You can also open the ⋮ menu at the top right and tap ☆ to bookmark it, or choose Add to Home screen.You can also tap ··· at the top right and choose Favorite, or open it in your browser and bookmark it there.
Problem or suggestion?Send feedbackChat with support
Version v1.0Updated Update history
Tracks, areas and lines
Grid describes a layout twice: the track sizes, then where each child goes.
- Drag to draw named areas
- fr, px, %, auto and minmax tracks
- Optional narrow-screen stacking

grid-template-columns and rows
One value per track. Equal neighbours are written as repeat(3, 1fr).
grid-template-areas
A picture of the layout in text: one quoted string per row, one word per column, a dot for an empty cell. Each name must fill a rectangle.
grid-area with line numbers
row-start / column-start / row-end / column-end. Lines are numbered from 1, so a block covering columns 1 to 3 ends at line 4.
gap
Space between tracks only, not around the outside; the preview’s outer space comes from padding.
Empty cells and auto placement
Cells without a name stay empty. Children without a grid-area flow into free cells in source order, row by row, and new implicit rows appear if there is no room left.
Canvas versus preview
The canvas is a map with equal columns so it is easy to draw on a phone. The preview applies your real track sizes, so a 160 px sidebar looks narrow there even though it looks like a third on the map.
Named areas read well for page layouts. Line numbers suit repeated component grids, such as a twelve-column system, where naming every cell would be noise.
Layout in four steps
Tracks first, areas second.
-
1
Count the tracks
Use the plus and minus buttons for columns and rows, or start from a preset.
-
2
Size them
Type a size into each box. Mix fixed sidebars with
1frcontent. -
3
Draw areas
Drag across cells, then rename the area to something meaningful such as
navorchart. -
4
Copy
Take the CSS and HTML. Turn on narrow-screen stacking if you want a one-column phone layout.
What the units do
Fixed tracks are subtracted first, then fr shares what is left.
fris a share of leftover space after fixed tracks and gaps1frhas an automatic minimum: long content can widen it;minmax(0, 1fr)prevents that%is relative to the grid’s width or height, and gaps come on top of itautosizes to content and takes remaining space when nothing else claims it
Width of one fr
fr = (container − padding − gaps − fixed tracks) ÷ sum of fr
Applies when content is not forcing the track wider.
The sample layout at 760 px wide
Columns 160px 1fr 1fr, rows 64px 1fr 56px, height 340 px, 12 px padding and gap, border-box sizing.
| Quantity | Calculation | Result |
|---|---|---|
| Content width | 760 − 2 × 12 | 736 px |
| Each fr column | (736 − 2 × 12 gaps − 160) ÷ 2 | 276 px |
| Content height | 340 − 2 × 12 | 316 px |
| Middle row (1fr) | 316 − 2 × 12 gaps − 64 − 56 | 172 px |
| main area | columns 2–3: 276 + 12 + 276 | 564 × 172 px |
On a 375 px phone the same 160 px sidebar would take close to half the width, which is a good reason to turn on stacking.
Where grid code goes wrong
Each one is quick to spot once you know it.
An area that is not a rectangle
An L-shaped name invalidates the whole grid-template-areas declaration. The canvas here only draws rectangles.
A column that blows out
A wide table or long URL stretches a 1fr column. Use minmax(0, 1fr) and let the content scroll.
Off-by-one lines
Three columns have four lines. Ending at line 3 covers only two columns.
Fixed columns on phones
A 240 px sidebar leaves little room at 360 px. Stack the areas in a media query.
Design for the screens your visitors have
Breakpoints are a guess until you see real widths.
Screen ranges of real visitors
The audience page groups visitors into nine CSS width ranges, from under 375 to 2560 and up.
Learn moreLayout shift in the field
CLS and other web vitals measured in visitors’ browsers, by page and device type.
Learn morePage-level reports
See which pages visitors land on and leave from after a redesign.
Learn moreCSS Grid questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
How do I create a grid layout in CSS?
Set display: grid on the container, define grid-template-columns and, if needed, rows, then place children with grid-area or let them flow automatically.
What does 1fr mean?
One share of the space left after fixed tracks and gaps. With 1fr 2fr the second column gets twice the leftover space of the first.
How do grid-template-areas work?
Each quoted string is a row and each word a column. Repeat a name to span cells; use a dot for empty cells. The named cells must form a rectangle.
How do I make the grid responsive?
Either redefine the areas in a media query, as the stacking option does, or use repeat(auto-fit, minmax(220px, 1fr)) for card grids that change column count by themselves.
When should I use grid instead of flexbox?
When rows and columns need to line up, as in page layouts, dashboards and forms. For a single wrapping line of items, flexbox is simpler.
How do I center content inside a grid cell?
Add place-items: center to the container to center every child in its area, or place-self: center to one child. justify-content and align-content move the whole set of tracks when they are smaller than the container.
Can I use this on a phone?
Yes. The canvas accepts touch dragging, and the track inputs and area editor work with the on-screen keyboard.
Is my layout sent anywhere?
No. It is built in your browser; the share link keeps it after the # in the address.
Is this tool working for you?
Rate it, or tell us what went wrong and what you’d like improved. A person reads every message, and frequent requests go into the next update.
Need help right now?
Chat with our support team, best for urgent problems; you can leave a message when we are offline.
Chat with supportUpdate history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
Recommend this tool in an article or on your site
This tool is free to cite and share. Copy the URL or link below into your article, tutorial or resource page; to write a review, embed a tool or partner with us, get in touch.
https://tapcub.com/tools/css-grid-generator<a href="https://tapcub.com/tools/css-grid-generator">CSS Grid generator - TapCub</a>Fill the areas
Lay out the inside of each area, then add depth.