The grid-template-rows property defines the number and size of row tracks in a CSS grid container.
01
Rows
Track sizes.
02
none
Default.
03
1fr
Flexible.
04
auto
Content.
05
repeat()
Patterns.
06
minmax()
Range.
Fundamentals
Introduction
The grid-template-rows property in CSS is a key component of the CSS Grid Layout system. It defines the size of each row in a grid container, allowing you to create complex and responsive grid layouts. This property helps in organizing and aligning grid items within rows, providing control over the layout of your web content.
Definition and Usage
Set grid-template-rows on a grid container with display: grid. List track sizes separated by spaces, or use functions like repeat() and minmax() for flexible patterns. Pair with grid-template-columns to define the full grid structure.
💡
Beginner Tip
100px 1fr auto creates three rows: a fixed header height, a flexible main area, and a footer sized by its content.
Foundation
📝 Syntax
The syntax for the grid-template-rows property uses a space-separated list of row sizes. Each size can be a length, a percentage, the fr unit, or the auto keyword:
With min-height: 100vh, the middle 1fr row fills all space between the fixed header and footer.
A11y
♿ Accessibility
Ensure sufficient row height for readable text and touch targets.
Test at narrow and zoomed viewports when using fixed pixel row heights.
Keep DOM order logical when rows reorder visually on small screens.
Use semantic HTML such as <header>, <main>, and <footer>.
Do not rely on row position alone to convey meaning; use headings and landmarks.
🧠 How grid-template-rows Works
1
Grid container is created
display: grid enables grid formatting context.
Grid
2
Row tracks are defined
You list sizes like px, fr, auto, or repeat() for each row track.
Rows
3
Browser sizes tracks
Fixed sizes apply first; fr units share remaining vertical space.
Sizing
=
▦
Structured row layout
Items auto-place into rows or span them with grid placement properties.
Compatibility
🖥 Browser Compatibility
The grid-template-rows property is widely supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.
✓ Baseline · Modern browsers
grid-template-rows everywhere
Row track sizing works in all major modern grid implementations.
97%Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox52+ · Desktop & Mobile
Full support
Apple Safari10.1+ · macOS & iOS
Full support
Microsoft Edge16+ · 79+ Chromium
Full support
Opera44+
Full support
grid-template-rows property97% supported
Bottom line: Safe for modern projects. Set container height when using fr row tracks.
Wrap Up
🎉 Conclusion
The grid-template-rows property is essential for creating well-structured grid layouts in CSS. By defining the size of rows, you can create flexible and responsive designs that adapt to different screen sizes and content types.
Experiment with various values to see how they affect the layout and achieve the design you envision. Start with fixed, fr, and auto rows, then explore repeat() and minmax() for more control.