HTML Guides for grid-template-rows
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The grid-template-rows property defines the size of each row in a CSS grid layout. The W3C validator checks that every value in the declaration conforms to the CSS Grid specification. When you see this error, the validator has encountered something it cannot parse as a valid track size.
Common causes of this error include:
- Typos or invalid units — writing
100 px(with a space),100pixels, or1 frinstead of1fr. - Using values from other properties — for example,
flex,inline, orspace-betweenare not valid row track sizes. - Incorrect function syntax — missing commas in
repeat(), providing wrong arguments tominmax(), or using unsupported functions. - Missing units — writing a bare number like
100instead of100px(zero is the only number that doesn't require a unit). - Using newer syntax not yet recognized — some cutting-edge features like
subgridor themasonryvalue may trigger validation warnings depending on the validator's supported spec level.
The grid-template-rows property accepts these valid value types:
- Length values:
100px,5em,10rem,20vh - Percentages:
50%,33.3% - Flexible lengths:
1fr,2fr - Keywords:
auto,min-content,max-content,none - Functions:
repeat(),minmax(),fit-content() - Named lines:
[row-start] 100px [row-end]
This matters for standards compliance and forward compatibility. While browsers may be lenient and ignore invalid values, relying on that behavior can lead to layouts that silently break. Valid CSS ensures your grid behaves predictably across all browsers.
Examples
Incorrect — invalid values
<style>
/* ERROR: "full" is not a valid track size */
.grid-a{
display: grid;
grid-template-rows: full auto;
}
/* ERROR: space between number and unit */
.grid-b{
display: grid;
grid-template-rows:100 px 200 px;
}
/* ERROR: bare number without a unit */
.grid-c{
display: grid;
grid-template-rows:100200;
}
/* ERROR: missing comma in repeat() */
.grid-d{
display: grid;
grid-template-rows:repeat(31fr);
}
</style>
Correct — valid track sizes
<style>
/* Fixed pixel heights */
.grid-a{
display: grid;
grid-template-rows:100px auto;
}
/* Flexible units */
.grid-b{
display: grid;
grid-template-rows:1fr2fr;
}
/* Repeat function with correct syntax */
.grid-c{
display: grid;
grid-template-rows:repeat(3,1fr);
}
/* Minmax with auto */
.grid-d{
display: grid;
grid-template-rows:minmax(100px,1fr) auto;
}
</style>
Full working example
<!DOCTYPE html>
<htmllang="en">
<head>
<title>Grid template rows example</title>
<style>
.grid-container{
display: grid;
grid-template-rows:80pxminmax(150px,1fr) auto;
gap:8px;
height:400px;
}
.grid-container>div{
background:#e0e0e0;
padding:16px;
}
</style>
</head>
<body>
<divclass="grid-container">
<div>Row 1 — fixed 80px</div>
<div>Row 2 — between 150px and 1fr</div>
<div>Row 3 — auto-sized to content</div>
</div>
</body>
</html>
Using fit-content() and named lines
<style>
.grid{
display: grid;
grid-template-rows:[header]fit-content(100px)[main]1fr[footer] auto;
}
</style>
If your value looks correct but the validator still flags it, check whether you're using a very new CSS feature like subgrid or masonry. These may not yet be recognized by the validator even if some browsers support them. In that case, the warning can be acknowledged while keeping the value intentionally.
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries