Skip to the page
css reference · grid

CSS display: grid

type
property value
applies to
a container, changing how its direct children lay out
inherits
no
common values
grid, inline-grid

Where it goes

On the parent. On its own it does almost nothing you can see. Pair it with grid-template-columns to define the columns, and gap for spacing.

Example

.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

Common mistakes

  • Using grid for a simple row of items that just need to sit side by side. Flexbox is simpler there. Grid earns its keep when both rows and columns must line up.
  • Setting grid properties on the children and expecting a layout. Like flexbox, the parent owns the layout. Children only need rules if they span cells.
  • Forgetting gap and adding margin to every child. gap puts even space between cells without the extra space at the edges that margins leave.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.