Utilumo
LightDarkSystem

Updated June 29, 2026

CSS Grid cheat sheet

Grid lays out content in rows and columns at the same time. You define tracks on the container, then place items into them. These are the properties you reach for most.

On the container

PropertyWhat it does
display: gridTurns an element into a grid container.
grid-template-columns: 1fr 1frDefines the column tracks.
grid-template-rows: auto 1frDefines the row tracks.
gap: 1remSets spacing between rows and columns.
grid-template-areas: "a b"Names regions for items to slot into.
justify-items: centerAligns items along the row (inline) axis.
align-items: centerAligns items along the column (block) axis.

On the items

PropertyWhat it does
grid-column: 1 / 3Span from column line 1 to 3.
grid-row: 1 / 2Span from row line 1 to 2.
grid-column: span 2Span two columns from the current position.
grid-area: aPlace the item into a named area.
justify-self: endAlign a single item on the row axis.

Track sizing

ValueWhat it does
1frOne fraction of the leftover space.
minmax(150px, 1fr)At least 150px, growing to fill space.
repeat(3, 1fr)Three equal columns.
repeat(auto-fit, minmax(200px, 1fr))Responsive columns that wrap to fit.
autoSized to the item's content.
Grid vs FlexboxGrid is two-dimensional (rows and columns together); Flexbox is one-dimensional (a single row or column). Use Grid for page-level layout and Flexbox for a row of controls. See the Flexbox cheat sheet.

References

Questions

What does the fr unit mean?

fr is a fraction of the available space in the grid. Two columns of 1fr each split the leftover space equally; 2fr and 1fr split it two-to-one.

When should I use Grid instead of Flexbox?

Use Grid when you need to control rows and columns together, like a page layout. Use Flexbox for one direction at a time, like a toolbar of buttons.