CSS: grid-template-rows

The grid-template-rows property defines the sizes of row tracks in a Grid container.

What you will learn

Minimal example

.layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

This pattern can give a layout a content-sized header and footer with a flexible middle row. Choose sizes that still work when content grows or the viewport becomes short.

Common mistakes