Free CSS Grid Generator

Build CSS Grid layouts visually · set columns, rows, gap & alignment, see live preview, copy the CSS.

Grid Properties

Preview

Generated CSS

How It Works

  1. Set grid dimensions: enter the number of columns and rows for your grid layout.
  2. Define tracks: set the width of each column and height of each row using fr units, pixels, percentages, auto, or minmax().
  3. Copy the CSS: the generated display: grid, grid-template-columns, grid-template-rows, and gap properties are ready to paste into your stylesheet.

Why Use CSS Grid Generator?

CSS Grid is the most powerful layout system in CSS, capable of creating complex two-dimensional layouts that previously required tables, floats, or JavaScript. But mastering grid-template-columns, fr units, minmax(), repeat(), and named areas takes practice. This visual generator lets you build any grid layout by clicking and dragging, then outputs clean CSS that you can use immediately or study to deepen your understanding of Grid.

Features

Frequently Asked Questions

What is a "fr" unit in CSS Grid?

The fr (fraction) unit distributes available space proportionally. In a 3-column grid with 1fr 2fr 1fr, the middle column gets twice as much space as the outer columns. fr units fill remaining space after fixed-size tracks are allocated.

How do I make a responsive grid without media queries?

Use repeat(auto-fill, minmax(200px, 1fr)) for the grid-template-columns value. This creates as many columns as fit at the minimum size, expanding to fill available space. Items automatically reflow as the container width changes.

What is the difference between grid-template and grid-auto?

grid-template-columns/rows defines explicit tracks that you specify. grid-auto-columns/rows defines the size of implicit tracks, columns and rows created automatically when items overflow the explicit grid.

A Short History of CSS Grid

Before CSS Grid, web layouts went through three painful eras. Table-based layouts (1995-2008) abused the <table> element for visual structure, with «slicing and dicing» Photoshop comps into HTML grids. Float-based layouts (2008-2013) replaced tables with the float property, requiring «clearfix» hacks like Nicolas Gallagher's micro-clearfix (2011) to contain wrapped children. Flexbox (CSS Flexible Box Layout Module Level 1, W3C Recommendation 2018) solved one-dimensional layouts but struggled with true two-dimensional grids. The CSS Grid story began with Microsoft's -ms-grid implementation in Internet Explorer 10 (2012), an early take that informed the W3C specification. The first W3C public working draft of CSS Grid Layout Module Level 1 dropped in April 2011, but real momentum came from advocacy work by Rachel Andrew (her book Get Ready for CSS Grid Layout, 2016) and Jen Simmons (Mozilla developer advocate, 2016-2018 conference circuit). The browser race resolved in a remarkable two-month window in March 2017: Chrome 57, Firefox 52, Safari 10.1, and Edge 16 all shipped unprefixed Grid within weeks of each other. The W3C marked Grid Level 1 a Candidate Recommendation in December 2016; the final W3C Recommendation arrived in August 2020. Subgrid (Level 2) shipped in Firefox 71 (Dec 2019), Safari 16 (Sept 2022), and Chrome 117 (Sept 2023). The next frontier is the proposed Masonry layout (CSS Working Group 2020 proposal, Firefox flag-gated since 2021).

The Anatomy of a CSS Grid

Real-world Grid Patterns

Standards and Milestones

More frequently asked questions

When should I use Grid vs Flexbox?

The community shorthand: Flexbox is for one dimension, Grid is for two. If you're laying out a row of buttons or aligning items in a single direction, Flexbox is simpler. If you're designing a whole-page layout with rows and columns that must align, Grid is the right tool. Many real layouts combine both: Grid for the page skeleton, Flexbox for component-level alignment within each grid area. Modern frameworks (Tailwind, Bootstrap 5) embrace this pattern.

Does CSS Grid work in older browsers?

All evergreen browsers (Chrome, Firefox, Safari, Edge) support Grid since March 2017. Internet Explorer 11 has only the early -ms-grid syntax (subset, prefixed, missing many features). For IE11 support, use @supports queries to fall back to Flexbox or float layouts. As of 2024, IE11 has <0.5% global usage, so most teams have dropped the fallback. Caniuse.com reports 97%+ global support for unprefixed Grid.

What is the difference between grid-template-areas and grid-area?

grid-template-areas is set on the grid container and visually maps out the named regions of the grid (one string per row). grid-area is set on a grid item to assign it to one of those named regions. The two work together: container declares the «map», items declare «I'm region X». You can also use grid-area directly with line numbers (grid-area: 1 / 1 / 3 / 4) instead of names, which is useful for dynamic layouts.

What is subgrid and when should I use it?

Subgrid lets a nested grid inherit its parent grid's track definitions instead of creating its own. This solves the problem of aligning items across nested grids, for example, a card with internal layout that must align with surrounding cards. Use grid-template-columns: subgrid on the nested grid. Available in Firefox 71+ (Dec 2019), Safari 16+ (Sept 2022), Chrome 117+ (Sept 2023). Falls back to a regular nested grid in unsupporting browsers.

How does Grid interact with accessibility?

Grid placement does not change the DOM source order: items appear in the visual position you assign, but screen readers and keyboard tab order follow the source. WCAG 2.1 SC 1.3.2 Meaningful Sequence requires the source order to make sense when styles are stripped. The implication: design your DOM source for logical reading order first, then use Grid to place items visually. If you reorder items dramatically with grid-column: 3 / 5; grid-row: 2, audit with a screen reader to confirm the spoken order still makes sense.

Related Tools

CSS Box Model CSS Columns Flexbox Generator CSS Clip Path