TapCub is live — analytics, insights and live chat, free on one platform

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.

Generator

Draw areas

header
sidebar
main
footer

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

CSS
/* 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;
}
HTML
<div class="grid">
  <div class="header">header</div>
  <div class="sidebar">sidebar</div>
  <div class="main">main</div>
  <div class="footer">footer</div>
</div>
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

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

Read the output

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
CSS Grid generator illustration: Set columns and rows, drag across cells to draw areas and copy grid-template-areas or line-based CSS
CSS Grid generator, illustrated

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.

How to use it

Layout in four steps

Tracks first, areas second.

  1. 1

    Count the tracks

    Use the plus and minus buttons for columns and rows, or start from a preset.

  2. 2

    Size them

    Type a size into each box. Mix fixed sidebars with 1fr content.

  3. 3

    Draw areas

    Drag across cells, then rename the area to something meaningful such as nav or chart.

  4. 4

    Copy

    Take the CSS and HTML. Turn on narrow-screen stacking if you want a one-column phone layout.

Track sizing

What the units do

Fixed tracks are subtracted first, then fr shares what is left.

  • fr is a share of leftover space after fixed tracks and gaps
  • 1fr has 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 it
  • auto sizes 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.

Worked example

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.

Track sizes of the sample grid at 760 px width
QuantityCalculationResult
Content width760 − 2 × 12736 px
Each fr column(736 − 2 × 12 gaps − 160) ÷ 2276 px
Content height340 − 2 × 12316 px
Middle row (1fr)316 − 2 × 12 gaps − 64 − 56172 px
main areacolumns 2–3: 276 + 12 + 276564 × 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.

Common mistakes

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.

FAQ

CSS 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.

Feedback

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.

Rate this tool

Please don’t include passwords or other sensitive information.

Only used to reply to this feedback.

Type, details and email are required.

We only use this to handle your feedback. See the privacy policy.

Feedback received

Thank you! We will read it and reply from hello@tapcub.com if needed.

Need help right now?

Chat with our support team, best for urgent problems; you can leave a message when we are offline.

Chat with support
Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · 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

Cite this tool

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.

URL
https://tapcub.com/tools/css-grid-generator
HTML link
<a href="https://tapcub.com/tools/css-grid-generator">CSS Grid generator - TapCub</a>

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics