Skip to main content

developer tool

CSS Grid Generator

Create CSS Grid layouts with a live visual playground. Customize columns, rows, gaps and alignment, position up to 24 items, explore eight editable presets and copy the CSS that drives the preview.

Loading tool…

Guide

CSS Grid Generator online

Build a two-dimensional layout with this visual CSS Grid playground. Choose explicit column and row tracks, select numbered items and edit their placement without changing their source order. The preview uses the same validated values as the CSS Grid code generator. Settings are processed locally in your browser without sending them to a layout processing service.

How to Use the CSS Grid Generator

1

Configure the grid

Choose 1–12 columns and rows. Use equal fractional tracks, auto sizing, repeated pixel sizes or a custom value for each track. Set a fluid or fixed container width and adjust the height.

2

Adjust tracks and spacing

Set Gap from 0px to 100px for both axes, or edit row-gap and column-gap independently. Compare item alignment inside each area with content alignment for the whole set of tracks.

3

Position individual items

Select any of the 1–24 items in the preview or item selectors. Keep automatic placement or set a numbered start line, a span or an explicit end line. Manual areas can overlap and positions outside the template create implicit tracks.

4

Preview and copy CSS

Try one of eight presets, then edit it. Copy Container CSS, Item CSS or All CSS and use the matching HTML class names. Reset restores three columns, two rows and six automatically placed items.

What CSS Grid Is

CSS Grid coordinates rows and columns in a two-dimensional layout. Setting display: grid makes direct children grid items. Track definitions establish the explicit grid, while item placement and auto-placement determine where content goes. This CSS Grid Maker uses the browser layout engine, so changes are rendered as actual CSS Grid rather than simulated coordinates.

CSS Grid vs Flexbox

Grid is useful when rows and columns need shared track boundaries, such as dashboards or magazine layouts. Flexbox distributes items along one main axis and lets each wrapped line distribute space independently. Use the related CSS Flexbox Generator for navigation bars or a simple aligned row; choose Grid when both dimensions need coordination.

Understanding grid-template-columns

grid-template-columns defines explicit column tracks. Equal mode exports repeat(N, 1fr), Auto repeats auto and Fixed repeats a pixel size. Custom mode accepts one value per column, such as 220px 1fr for a sidebar and content area. This Grid Template Columns Generator supports up to twelve explicit columns. It deliberately excludes functions and named lines from custom text to keep serialization bounded and safe.

Understanding grid-template-rows

grid-template-rows defines the explicit rows using the same sizing choices. Fractional rows divide the available height after gaps and other tracks, while auto rows respond to intrinsic content and alignment. The preview has an adjustable definite height from 120px to 900px. Demo items have a 48px minimum height plus their box sizing rules, so very small tracks can show overflow.

Fractional Units (fr)

A fractional unit represents a share of available grid space. With 1fr 2fr, the second track receives twice the flexible share of the first after other sizes and gaps are accounted for. Intrinsic minimums can constrain this distribution. Custom tracks support fr, px, %, rem, em, vw and vh plus auto; the UI explains the bounds. Viewport and font-relative units resolve against their normal CSS references, not against an artificial preview scale.

Row-gap and Column-gap

row-gap separates rows and column-gap separates columns. Gap updates both controls together; editing either axis then overrides only that axis. The export writes gap followed by both longhands in the same order as the preview values. Percentage tracks plus pixel gaps can exceed the container width. Content distribution such as space-between can add space beyond the chosen gap.

Grid Item Placement

Automatic starts let the browser place items using row auto-flow. For manual positioning, select positive start lines from 1 to 24 and either a span or a later end line up to 37. An explicit end line requires a numbered start in this editor. grid-column and grid-row shorthands encode the corresponding start and end longhands. Changing track count preserves manual settings; covered items remain selectable using the controls.

Grid Column and Row Spanning

A span counts tracks rather than line numbers. For example, grid-column: 1 / span 2 starts at line 1 and covers two columns. grid-row follows the same pattern vertically. Spans range from one to twelve. Two items assigned intersecting manual areas can overlap, with later items painting over earlier ones. The playground warns about definite manual intersections and keeps those settings intact rather than moving items automatically.

Building Responsive CSS Grid Layouts

Fluid width adapts the container to the available page width; fixed width lets you inspect a specific size with scrolling on smaller screens. Fractional tracks distribute the available space, but a fixed track count does not automatically collapse into fewer columns. Use this Responsive CSS Grid Generator to explore widths, then add your own media queries or auto-fit/minmax templates in the final project. The tool exports the configured layout and does not invent breakpoint rules.

Explicit and Implicit Grid Tracks

The chosen row and column counts define explicit tracks. Additional items, spans or manual positions outside those tracks can create implicit tracks. This editor exports grid-auto-rows: auto, grid-auto-columns: auto and grid-auto-flow: row so the browser handles them consistently in the preview and copied CSS. A template with two rows can therefore display more than two rows. Overflow is scrollable rather than hidden or silently clamped.

Container Alignment and Item Alignment

justify-items and align-items align items inside their grid areas, with justify-self and align-self overriding individual items. justify-content and align-content distribute the tracks within the container. Content alignment is most visible when the tracks occupy less space than the container; small fixed tracks make this easy to inspect. Fully flexible tracks can consume all spare space and leave little visible difference between content alignment values.

Common uses for CSS Grid Generator

  • Prototyping a sidebar beside a flexible content area
  • Arranging dashboard panels with shared row and column boundaries
  • Exploring gallery and magazine item spans
  • Learning how track sizing, gaps and alignment interact

Why use this developer tool?

  • Generate and preview native CSS Grid from one validated set of values.
  • Edit explicit tracks and inspect browser-created implicit tracks.
  • Keep stable item numbers while editing spans, end lines and self alignment.
  • Export separate container and item rules with matching example HTML.

CSS Grid Generator FAQ

What is CSS Grid?

CSS Grid is a two-dimensional CSS layout system for arranging direct children into coordinated rows and columns.

How do I create a grid layout in CSS?

Set display: grid on a parent, define grid-template-columns and optionally grid-template-rows, then add gap and item placement rules. Copy both CSS sections and use the matching HTML classes from this tool.

What is the difference between CSS Grid and Flexbox?

Grid coordinates two dimensions with shared tracks. Flexbox focuses on a main axis; separate wrapped lines distribute their items independently.

What does 1fr mean in CSS Grid?

It is one share of the available flexible track space after gaps and other sizes. Intrinsic minimums can still constrain the resulting size.

How do I create equal-width columns?

Choose Equal sizing and a column count. The tool exports repeat(N, 1fr), with demo items using min-width: 0 so long content can wrap.

How do I make an item span multiple columns?

Select the item, choose Span as its column end mode and increase the span. A rule such as grid-column: 1 / span 2 covers two columns from line 1.

How do I change grid gaps?

Gap sets both axes from 0px to 100px. Row gap and Column gap independently override the corresponding spacing.

Can I create responsive layouts with CSS Grid?

Yes. Flexible tracks adapt to available space. This tool previews fluid or fixed widths, while breakpoint media queries and auto-fit/minmax templates can be added separately in your project.

Can I copy the generated CSS?

Yes. Copy Container CSS, Item CSS or All CSS. If clipboard access is blocked, select the displayed code and copy it manually.

Is the CSS Grid Generator free?

Yes. The live playground, eight editable presets and all CSS copy actions are free without signup.

Related Tools