Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Grid

The grid-auto-rows property

Reference for the CSS grid-auto-rows property: size the implicit rows a grid creates for extra items, with minmax(), examples, syntax and usage notes.

The grid-auto-rows property sets the height of the implicit rows of a grid: the rows the browser creates when there are more items than the template has room for. By default these rows are auto, which sizes them to their content, so the layout often looks uneven. Setting grid-auto-rows gives every generated row the same, predictable rule.

CSS
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(60px, auto);
}

Try it

Equal heights for generated rows

Syntax

CSS
grid-auto-rows: <track-size>+;
  • Initial value: auto
  • Applies to: grid containers
  • Inherited: no
  • Animatable: yes, between lists with the same number of compatible values; other values change abruptly
  • Computed value: the list, with lengths made absolute

Values

Value Description
auto Sized to content.
<length> / <percentage> A fixed height. Percentages need a container with a definite height.
<flex> (1fr) A share of free space; only works when the container height is definite.
min-content / max-content The shortest or tallest content-based height.
minmax(min, max) A range. minmax(100px, auto) means "at least 100px, taller if the content needs it".
Several values Applied in sequence and repeated.

Usage notes

  • Use minmax(Xpx, auto) for cards. A fixed height clips text the moment content grows; the minmax form is safe.
  • Rows are implicit only. Rows from grid-template-rows keep their sizes.
  • Alternating patterns. grid-auto-rows: 80px 160px produces tall and short rows in turn.
  • 1fr rows need a height. In an auto-height container there is no free space to share, so such rows collapse to content size.
  • Combine with dense. Fixed row heights plus grid-auto-flow: dense is the classic tile-gallery recipe.

Browser support

Supported in all current browsers.