b2KIT

CSS Grid Generator

Design CSS Grid layouts visually with template columns, rows, gap, and area naming with code export.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Grid Generator does, with a checked example

Lay out the tracks first, then name the regions: CSS Grid Generator converts those visual choices into CSS for an explicit grid container. Configure column and row track lists, choose the gutter size, and assign names across cells; the export records them as grid-template-columns, grid-template-rows, gap, and grid-template-areas. The frequent surprise is that an area name does not place an element automatically. A child still needs a matching grid-area value, or another grid placement rule, to occupy that region.

Worked example

A concrete input and expected output from the current implementation.

Input

Columns: 1fr 2fr
Rows: 48px 120px
Gap: 8px
Areas:
header header
nav main

Expected output

display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: 48px 120px;
gap: 8px;
grid-template-areas:
  "header header"
  "nav main";

The two area rows each contain two tokens, matching the two columns. Header occupies both cells in the first row, while nav and main occupy the left and right cells of the second row; gap creates an 8px row gutter and an 8px column gutter.

How the result is produced

1

Track definitions

Columns and rows are independent ordered track lists. Entering 1fr 2fr for columns creates two flexible column tracks with flex factors of 1 and 2; entering 48px 120px for rows creates two fixed-height tracks. The gap sits between tracks rather than adding an outer margin. Content sizing can still affect flexible tracks, so the preview is not a pixel calculator.

2

Named area map

The area map becomes quoted rows in grid-template-areas, with one token for each grid cell. Repeating the same name across neighboring cells defines one named region only when those cells form a rectangle. Every quoted row must contain the same number of tokens. An unnamed cell is represented in CSS by a dot placeholder.

Good uses

  • Draft a documentation shell with a header spanning two tracks and navigation beside the article.
  • Turn a dashboard wireframe into named regions such as header, sidebar, main, and footer before assigning widgets.
  • Compare track ratios and gutters for a card or gallery layout, then copy the resulting grid-container CSS into a prototype.

Limits and checks

  • An area name cannot describe an L-shape or disconnected cells. If it does, the entire grid-template-areas declaration is invalid, not merely that name.
  • Grid-template-areas does not match HTML class names automatically. Verify that every intended grid item has grid-area set to its region name or uses explicit grid-line placement.
  • Fractional values divide available leftover space, not the container's raw width. Gaps, fixed tracks, intrinsic item minimums, padding, and borders can alter the visible proportions.

Common questions

Can the same area name appear in multiple cells?

Yes, when every occurrence forms one filled rectangle. For example, two adjacent header cells create an area spanning two columns. No, the same name cannot validly describe separated islands or an L-shape in one grid-template-areas declaration. Use distinct names or line-based placement for those cases.

Will the exported grid make my page responsive?

Not by itself. Flexible tracks such as fr units respond to available space, but the number and arrangement of tracks remain as declared. To change a two-column area map into one column, provide another grid template under a media query or container query. Test long content because intrinsic minimum sizes can also prevent expected shrinking.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools