CSS Subgrid: Align Nested Grid Items with Parent Tracks
How subgrid lines up nested grid items with the parent's tracks. Measured in Chromium: three cards misaligned by up to 105px without it, aligned with it, and fully overlapping when the card forgets grid-row: span.
What Subgrid Solves
A grid item that is itself a grid normally gets its own, independent tracks. Put three cards side by side, each a small grid of title, description and footer, and each card sizes its rows from its own content: a two-line title pushes that card's description down, and nothing lines up across the row. subgrid lets the card use the parent grid's tracks instead, so every card's title row is as tall as the tallest title.
Worked Example: Three Cards, Measured
In Chromium we laid out three 200px cards whose titles wrap to one, two and four lines, and measured where each card's description starts (October 13, 2026; script in our test folder):
| Card CSS | Description top (cards 1, 2, 3) | Footer top |
|---|---|---|
Nested grid: grid-template-rows: auto auto 1fr | 26, 52, 131 px: misaligned | 49, 75, 153 px |
grid-row: span 3; grid-template-rows: subgrid | 139, 139, 139 px: aligned | 169, 169, 169 px |
grid-template-rows: subgrid without the span | 0, 0, 0 px: all three children overlap | 0, 0, 0 px |
The last row is the mistake to watch for. A subgrid only gets as many tracks as the item spans in the parent. Without grid-row: span 3 the card spans one row, so its title, description and footer are all placed in that single track, on top of each other. No error, just overlapping text.
The Pattern
.cards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 16px;
}
.card {
display: grid;
grid-row: span 3; /* one parent row per child */
grid-template-rows: subgrid; /* use the parent's rows */
row-gap: 8px; /* optional: override the inherited gap */
}
The parent does not need to declare the rows: implicit rows work, as in the test. A subgrid inherits the parent's gap on that axis unless it sets its own, and it can be used on columns, rows or both. The CSS Grid Generator helps prototype the parent tracks.
Where It Pays Off
- Card rows where titles, prices or buttons must line up across cards, the case measured above.
- Forms where labels in separate fieldsets should share one label column.
- Lists that behave like tables, such as a definition list or a list of settings rows with aligned columns, while keeping list semantics.
Browser Support
MDN's compatibility data lists subgrid in Firefox 71, Safari 16 and Chrome and Edge 117, and caniuse (data of October 13, 2026) puts global support at 94.4%. Browsers without it ignore the value, so the card falls back to its own rows: content stays readable, just unaligned. To style that fallback deliberately, test with @supports (grid-template-rows: subgrid).