Grid Row Track Property

Last updated: 2026-09-13

grid-template-rows Grid Row Track Property

The grid-template-rows property defines the number and height of the row tracks in a grid container. By specifying the size of each row track you control the row structure precisely. Used together with grid-template-columns, it forms the basic skeleton of the grid. It supports fixed lengths, percentages, the fr unit, and functions such as minmax().

Category
Initial Valuenone
InheritedNo
Applies To
Animation Type
CSS VersionCSS3
StatusStandard

📝 Syntax

grid-template-rows: none | <track-list> | <auto-track-list>;

⚙️ Values

ValueTypeDescription
noneKeywordNo explicit row tracks
<track-list>TypeRow track list

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
grid-template-rows v57 v16 v52 v10.1 v44
Supported in all major browsers
Tip: Combined with a fixed container height, 1fr lets a middle row fill the remaining space automatically - a classic trick for page layouts.
Tip: The auto keyword sizes the row from its content, which suits rows of varying height.

❓ FAQ

QDoes grid-template-rows require a fixed container height?
ANot necessarily. Without an explicit container height, the row tracks default to auto and are stretched by the tallest item content in that row. Only when you distribute the row heights proportionally with units such as fr does the container need a definite height as the basis for the calculation; otherwise fr degrades to the content height. Full-page layouts often give the container height: 100vh or a fixed height and use auto 1fr auto for the header, main and footer skeleton.
QHow do I make the row heights adapt to the content?
AWrite the row track size as auto, or simply omit grid-template-rows; each row height is then decided by its content - more content means a taller row. To enforce a minimum height, use grid-auto-rows: minmax(100px, auto), which keeps the rows at least 100px and lets them grow with the content. Note that the fr unit distributes the height proportionally and cannot adapt to the content.
QWhat does grid-template-rows: auto 1fr auto mean in a full-page layout?
AThis is the classic header-main-footer layout: the first row’s auto height is decided by the header content, the second row’s 1fr absorbs all the remaining container height so the main area stretches with the container, and the third row’s auto height comes from the footer content. Combined with grid-template-columns and a container height of 100vh, it produces a full-page skeleton where the main area is fluid while the header and footer never overflow.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏