CSS Grid Generator
Visual CSS Grid layout builder with code generation
Layout settings
Preset layouts
Per-item placement
Select an item in the preview or the list to edit its properties.
CSS Grid quick reference
Grid tracks
Use fr units for flexible tracks, px/% for fixed, and auto for content-sized tracks.
repeat() function
repeat(3, 1fr) is shorthand for 1fr 1fr 1fr. Use auto-fill or auto-fit for responsive grids.
Spanning items
Use span N to span N tracks, or 1 / -1 to span all columns/rows.
Live preview
Line labels show the first 200 tracks. Your full CSS and layout are retained.
Generated CSS
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: auto;
gap: 10px;
}Change the settings or select an item. The preview and CSS update together.
About CSS Grid Generator
The CSS Grid Generator is an interactive visual tool for designing and generating CSS Grid layouts. CSS Grid Layout is the most powerful two-dimensional layout system available in CSS, allowing you to define both columns and rows simultaneously. This tool provides a hands-on approach to learning, experimenting with, and generating production-ready CSS Grid code.
Key Features
- Full control over grid-template-columns and grid-template-rows with free-form input
- Quick column and row buttons for rapid prototyping with equal tracks
- Independent row-gap and column-gap sliders for precise spacing control
- justify-items and align-items alignment controls
- Per-item grid-column and grid-row placement with quick value buttons
- Custom labels for grid items to visualize semantic layout regions
- Pastel-colored numbered items with grid line number indicators
- Preset layouts: Blog Layout, Dashboard, Photo Gallery, and Landing Page
- Auto-generated CSS code with one-click copy
- Full dark mode support
Understanding CSS Grid
CSS Grid works by defining a grid container with explicit or implicit tracks (columns and rows). Items placed inside the container are automatically positioned into cells, or you can explicitly place them using grid-column and grid-row properties to span multiple tracks. The fr unit represents a fraction of available space, making responsive layouts straightforward. The repeat() function simplifies repetitive track definitions, and functions like minmax() and auto-fill/auto-fit enable truly responsive grids without media queries.
Common CSS Grid Layout Patterns
CSS Grid is ideal for page-level layouts such as blog designs with header, sidebar, content, and footer regions; dashboard interfaces with navigation, main content, and widget areas; photo galleries with items spanning multiple rows and columns for a masonry-like effect; and landing pages with full-width hero sections, multi-column feature grids, and call-to-action areas. Use the preset buttons to instantly explore these patterns.
Grid vs Flexbox
While Flexbox is designed for one-dimensional layouts (a single row or column), CSS Grid excels at two-dimensional layouts where you need control over both axes simultaneously. Grid is best for page layouts and complex component arrangements, while Flexbox is ideal for distributing space among items in a single line. Many modern designs use both together, with Grid for the overall page structure and Flexbox for component-level alignment.
Who Is This Tool For?
- Web developers building page layouts with CSS Grid
- Frontend engineers prototyping responsive grid systems
- UI/UX designers visualizing grid structures before implementation
- Students learning two-dimensional CSS layout techniques
- Educators teaching CSS Grid concepts in workshops or classes
- Anyone needing to quickly generate CSS Grid code for their web projects