CSS grid-template-rows Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The grid-template-rows property sets the size (and optional line names) of the explicit row tracks on a grid container (display: grid).

The initial value is none. Pair it with grid-template-columns for columns, or use the grid-template shorthand. Implicit rows use grid-auto-rows.

Standard-track.

Not deprecated and not experimental. Baseline widely available with CSS Grid. The subgrid value is newer—check support if you rely on it.

CSS Syntax

syntax.css
grid-template-rows: none | <track-list> | subgrid | initial | inherit;

A track list is one or more sizes such as 40px, 1fr, auto, minmax(), or repeat().

Property Values

ValueDescriptionTry it
noneDefault. No explicit rowsTry it
<length> / %Fixed or percentage row heightTry it
<fr>Share of remaining free space (needs a definite height)Try it
minmax() / repeat()Range size, or repeat a track patternTry it
initialResets to noneTry it
inheritTakes the parent value (not inherited by default)Try it

How to Use grid-template-rows

List one size per row, top to bottom. Give the grid a height when using fr.

  1. Set display: grid on the container.
  2. Write row sizes: grid-template-rows: 40px 1fr;.
  3. Set a definite height (for example height: 160px) so fr rows have free space to share.
  4. Use repeat() or minmax() for patterns and ranges.
ValueResult
40px 1frFixed header row + flexible body
1fr 1fr 1frThree equal rows
repeat(3, 1fr)Same as three 1fr tracks
minmax(40px, 1fr) 2frFirst row at least 40px; second gets twice the free space

Live Preview

Change only grid-template-rows. The demo box has a fixed height so fr can expand.

fr shares leftover height after fixed tracks. Without a definite height, fr rows often collapse to content size.

Rows
1
2
3

grid-template-rows: 1fr 1fr 1fr

CSS Examples

Each snippet focuses on grid-template-rows. Use Try It Yourself for a live editor.

Example 1 — Fixed + Flexible

A length sizes one row; 1fr takes the rest of the height.

CSS
<style>
  .grid {
    display: grid;
    height: 140px;
    grid-template-rows: 40px 1fr;
  }
</style>

<div class="grid">
  <div>1</div>
  <div>2</div>
</div>
Try It Yourself

How It Works

  1. Two tracks. The value lists two row sizes, so the grid has two rows.
  2. Fixed first. 40px locks the first row height.
  3. Flexible second. 1fr takes the remaining free height.
  4. Height matters. height: 140px gives fr a pool of free space to share.

Example 2 — Equal Rows with repeat()

repeat(3, 1fr) is a short form of 1fr 1fr 1fr.

CSS
<style>
  .grid {
    display: grid;
    height: 180px;
    grid-template-rows: repeat(3, 1fr);
  }
</style>

<div class="grid">
  <div>1</div>
  <div>2</div>
  <div>3</div>
</div>
Try It Yourself

How It Works

  1. Count first. repeat(3, …) builds three identical tracks.
  2. Equal share. Each track is 1fr, so free height splits three ways.
  3. Same as listing. This matches writing 1fr 1fr 1fr by hand.
  4. One item per row. Three children fill the three explicit rows.

Example 3 — minmax()

Give a row a minimum height while still allowing it to grow.

CSS
<style>
  .grid {
    display: grid;
    height: 160px;
    grid-template-rows: minmax(40px, 1fr) 2fr;
  }
</style>

<div class="grid">
  <div>1</div>
  <div>2</div>
</div>
Try It Yourself

How It Works

  1. Floor and flex. minmax(40px, 1fr) never shrinks below 40px and can grow with free space.
  2. Larger second share. 2fr gets twice as much free height as a 1fr track.
  3. Two rows. Items stack top to bottom into those tracks.
  4. Useful for headers. Keeps a readable minimum without locking a forever-fixed height.

Edge Cases & Pitfalls

Row fr tracks need free height. Watch container size and implicit rows.

height

fr needs a definite block size

If the grid’s height is only content-sized, 1fr rows often behave like auto. Set height, min-height, or fill a sized parent.

fr

fr shares leftover space

Fixed lengths are resolved first. Then fr tracks divide what remains—not the full container height by default.

none

none still allows implicit rows

With none, rows appear as needed and size via grid-auto-rows.

%

Percentages need a definite container size

If the grid’s block size depends on its tracks, browsers may treat a percentage like auto.

subgrid

subgrid inherits the parent track sizes

Use it only inside a nested grid that spans parent tracks. Support is solid in modern browsers, but verify if you target older ones.

Browser Support

grid-template-rows is a browser style property for CSS Grid. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

grid-template-rows

Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+, Opera, Samsung Internet 6+. Not supported in Internet Explorer.

96% global support
Google Chrome 57+
Full support
Mozilla Firefox 52+
Full support
Apple Safari 10.1+
Full support
Microsoft Edge 16+
Full support
Opera 44+
Full support
Samsung Internet 6+
Full support
Internet Explorer All
Not supported
grid-template-rows Supported with modern CSS Grid

Bottom line: Safe for modern grid layouts. No vendor prefix is required in current browsers.

Key Takeaways

  • Role: define explicit row count and heights.
  • fr: shares free height after fixed tracks—needs a definite container height.
  • Helpers: repeat() for patterns; minmax() for ranges.
  • Implicit: overflow rows use grid-auto-rows, not this property.

One line: grid-template-rows lists the heights of your explicit grid rows, top to bottom.

Frequently Asked Questions

It defines how many explicit row tracks a grid has and how tall each track is.
none — no explicit rows. Extra rows come from grid-auto-rows when items need them.
One share of the free space left after fixed-size row tracks are sized. The grid container needs a definite height for fr rows to expand.
A compact way to write 1fr 1fr 1fr — three equal flexible rows.
grid-template-rows sizes the explicit rows you declare. grid-auto-rows sizes implicit rows created by overflow or placement.
Baseline widely available: Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+. It is a browser style property, not a Node.js feature.

Next: hanging-punctuation

Control whether punctuation can hang outside the line box.

hanging-punctuation tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful