Skip to content
Latest: Publish JavaScript Packages to NPM Like a Pro!

grid-template-rows Property in CSS Grid Layouts

grid-template-rows specifies the number and heights of rows browsers should display in the selected grid container.

Example 1: How to Create a Three-Row Grid Container

section {
display: grid;
grid-template-rows: 95px 1fr 70px;
background-color: orange;
margin: 10px;
padding: 7px;
}
div {
background-color: purple;
color: white;
margin: 5px;
padding: 10px;
border-radius: 5px;
}

Try Editing It

The snippet above used the grid-template-rows property to display three rows of different heights in the selected <section> grid container.

Example 2: How to Create a Three-Row and Four-Column Grid Container

section {
display: grid;
grid-template-rows: 90px 300px 1fr;
grid-template-columns: auto auto auto auto;
background-color: orange;
margin: 10px;
padding: 7px;
}
div {
background-color: purple;
color: white;
margin: 5px;
padding: 10px;
border-radius: 5px;
}

Try Editing It

The snippet above used the grid-template-rows property to display three columns of different heights in the selected <section> grid container.