Skip to main content

CSS Grid Generator

Set columns, rows, column track sizes and gap, see a live grid preview and copy the CSS and HTML.

For developers who want a working grid container quickly.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

Reading the generated CSS

grid-template-columns defines the explicit column tracks. grid-template-rows does the same for rows. gap puts equal space between tracks in both directions. Children are placed automatically, left to right then top to bottom, until the cells are filled.

Example: 4 columns and 2 rows with template repeat(4, 1fr) and a 16px gap gives eight equal cells in two equal-height rows. A template like 200px repeat(3, 1fr) is not accepted, because repeat() has to be the whole value; write 200px 1fr 1fr 1fr instead. The error message tells you how many tracks the Columns field expects.

  • Fixed sidebar: 240px 1fr gives a sidebar plus fluid content.
  • Equal cards: repeat(3, 1fr) with a 16px gap.
  • Never narrower than 200px: minmax(200px, 1fr) per column.

Limits

The generator makes a plain explicit grid.

It does not produce auto-fill or auto-fit, named areas, subgrid, or item placement such as grid-column spans.

Preview items are the same size, so check your real content, and test at narrow widths where a fixed multi-column template may need a media query.

Sources

W3C CSS Grid Layout Module Level 1, sections 7.1 (explicit grid) and 7.2.3 (repeat notation), and Level 2 for track sizing. The gap property follows the W3C CSS Box Alignment Module Level 3, section 8.

Related tools: the CSS Flexbox Generator and PX to REM Converter.

Frequently Asked Questions

Common questions about the CSS Grid Generator

Two blocks: CSS and HTML. The CSS is a .container rule with display: grid, grid-template-columns, grid-template-rows and a pixel gap. The HTML is a div.container with one child div per cell, labeled Item 1, Item 2 and so on. Defaults give 3 columns as repeat(3, 1fr), 3 rows as repeat(3, 1fr) and an 8px gap, with 9 items.

From the same team

Turn your GPU into an OpenAI-compatible API endpoint

Wide Area AI routes your LLM API calls to your own hardware over a Cloudflare Tunnel — free local inference with edge caching and automatic cloud failover. Works with any OpenAI SDK.

Start routing — free

Sources & References

Web platform and protocol references

Authoritative definitions for web technologies, encodings, and data formats used by these developer tools.

Internet standards (RFCs)

Formal specifications for internet formats and protocols.