Visually design flexible, responsive CSS Grid layouts. Configure column & row tracks, adjust gaps, position grid items with spans or named areas, and export clean CSS and HTML.
. for empty grid cells.
Select any layout preset to immediately populate tracks, spans, items, and live CSS:
/* Generating CSS Grid... */
CSS Grid Layout is the most powerful 2-dimensional layout system available in CSS. Unlike Flexbox, which is primarily 1-dimensional (rows OR columns), CSS Grid can handle both columns and rows simultaneously, allowing precise control over elements spanning across multiple tracks.
display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: auto; gap: 16px;
Represents a fraction of the leftover available space in the grid container. For example, 1fr 2fr 1fr divides available free space into 4 parts, allocating 2 parts to the center track.
Defines a size range between a minimum and maximum limit, such as minmax(200px, 1fr). The track will never shrink narrower than 200px and will stretch up to 1fr.
auto-fit collapses empty tracks to 0px, expanding occupied items to fill the viewport. auto-fill preserves empty tracks even if no items occupy them.
Controls item boundaries using grid line coordinates: grid-row-start / grid-column-start / grid-row-end / grid-column-end, or shorthand span 2.
| Feature | CSS Grid Layout | CSS Flexbox |
|---|---|---|
| Dimensionality | 2-Dimensional (controls both columns & rows simultaneously) | 1-Dimensional (controls either a single row OR single column) |
| Design Approach | Layout-First (defines outer track matrix, places items into cells) | Content-First (flows items based on their intrinsic dimensions) |
| Overlap & Multi-Span | Native support for overlapping items with z-index & multi-cell spanning |
Items cannot overlap without negative margins or absolute positioning |
| Named Template Areas | Fully supported with visual ASCII strings via grid-template-areas |
Not supported |
| Ideal Use Cases | App dashboards, magazine layouts, full page structure, image galleries | Navbars, pill tags, button groups, simple linear card rows |
fr, pixels, percentages, and minmax()), and cell spanning without requiring floating elements or complex wrapper divs.
display: grid; to your container element and define two column tracks using grid-template-columns: 1fr 1fr; (for two equal-width columns) or grid-template-columns: 260px 1fr; (for a fixed-width sidebar alongside a fluid content area). Add gap: 16px; to introduce spacing between them.
fr unit represents a fractional share of the remaining available free space inside the grid container after fixed tracks (like pixels or content minimums) and gaps have been calculated. For instance, grid-template-columns: 1fr 3fr; divides free space into 4 parts, allocating 25% to the first column and 75% to the second.
grid-template-columns: 1fr 1fr 1fr;, or using the CSS repeat helper: grid-template-columns: repeat(3, 1fr);. This ensures all columns scale synchronously as the browser window resizes.
auto-fill maintains empty tracks, reserving empty column slots; whereas auto-fit collapses empty tracks to 0px, stretching the existing items to occupy the full container width.
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));, which automatically drops the column count as the screen shrinks; or (2) CSS Media Queries, where you redefine grid-template-columns at tablet (e.g. @media (max-width: 768px)) and mobile breakpoints.
grid-column: span 2; (or explicit line numbers like grid-column: 1 / 3;) and grid-row: span 2;. This is widely used for hero banner cards, wide headers, tall sidebar navigations, and staggered image galleries.
pacestools-grid.css stylesheet file that downloads straight to your device.