CSS Grid Generator
Build CSS Grid layouts interactively with live preview and get CSS or Tailwind code
Safe conversion with no data sent to server
Last updated: March 2026
display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; column-gap: 10px; row-gap: 10px; justify-items: stretch; align-items: stretch;
grid grid-cols-3 grid-rows-2 gap-x-[10px] gap-y-[10px] justify-items-stretch items-stretch
What is CSS Grid?
CSS Grid Layout is a powerful two-dimensional layout system for the web. It lets you lay content out in rows and columns simultaneously, making it perfect for complex page layouts that need precise control over both axes at once. Unlike Flexbox, which handles one direction (row or column), CSS Grid manages the entire page structure β headers, sidebars, main content, and footers β all in a single container with explicit row and column tracks.
You define the grid structure using grid-template-columns and grid-template-rows, then the browser places items automatically in order, or you can position them explicitly using grid-line-based placement. The fr unit, unique to Grid, distributes available space in flexible fractions.
Key CSS Grid Properties
- grid-template-columns β Defines column track sizes.
1fr 2fr 1frcreates three columns where the middle is twice as wide. - grid-template-rows β Defines row track sizes.
auto 1fr autocreates a header, flexible main, and footer. - column-gap / row-gap β Sets spacing between columns and rows (replaces the older
grid-gapsyntax). - justify-items β Aligns grid items within their cells along the row axis.
- align-items β Aligns grid items within their cells along the column axis.
- grid-column / grid-row β On individual items, spans across multiple tracks:
grid-column: 1 / 3.
The fr Unit and Responsive Grids
The fr unit is unique to CSS Grid and represents a fraction of the available space after fixed-size tracks are placed. 1fr 1fr 1fr creates three equal columns. 1fr 2fr 1fr makes the middle column twice as wide. Combined with repeat() and minmax(), fr units enable powerful responsive grids: repeat(auto-fill, minmax(250px, 1fr)) creates as many 250px+ columns as will fit, automatically reflow on smaller screens with zero media queries.
CSS Grid vs Flexbox
CSS Grid and Flexbox are complementary. Grid excels at two-dimensional layouts β defining the full page or section structure with explicit rows and columns for dashboards, card galleries, and complex page layouts. Flexbox is better for one-dimensional component-level layouts β navigation bars, button groups, toolbars, and centering items. Most modern designs use both: Grid for the overall page architecture and Flexbox for aligning content within each grid area or card. Understanding when each is appropriate is a core modern CSS skill.
Common Use Cases
- Full-page layouts with header, sidebar, main content, and footer areas
- Card gallery grids with responsive column count using
auto-fillandminmax() - Dashboard layouts with widgets spanning multiple columns and rows
- Magazine-style editorial layouts with varying-sized content blocks
- Image grids with specific items spanning multiple cells for visual emphasis
- Form layouts with labels and inputs aligned in a consistent two-column grid
FAQ
What does "fr" mean in CSS Grid?
The fr unit represents a fraction of the available space remaining after fixed-size tracks are allocated. 1fr 2fr 1fr creates three columns where the middle is twice as wide as the outer ones. Fractions are distributed proportionally, making fr ideal for flexible, responsive layouts.
How do I make a responsive grid without media queries?
Use grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)). This creates as many columns as will fit at a minimum of 250px wide, with each column growing to fill available space. As the viewport narrows, columns automatically drop to the next row β fully responsive with no media queries needed.
Is CSS Grid supported in all browsers?
Yes. CSS Grid is supported in all modern browsers including Chrome, Firefox, Safari, and Edge, with broad support since 2017. Subgrid (for nested grid alignment) has newer but growing support. For production use, basic CSS Grid is universally safe.
Related Design Tools Tools
HEX to RGB Converter
Instantly convert HEX color codes to RGB format for CSS
RGB to HEX Converter
Instantly convert RGB color values back to HEX format
HEX to Tailwind Color
Find the closest standard Tailwind CSS color corresponding to a HEX value
PX to REM Converter
Calculate REM values from pixels based on your root font size