CSSMay 8, 2026 Β· Updated Oct 13, 2026 Β· 3 min read

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.

πŸ“
Try the CSS Grid Generator
Free, no signup
β†’
DG
Derek Giordano
Designer & Developer
In this guide
01What Subgrid Solves02Worked Example: Three Cards, Measured03The Pattern04Where It Pays Off05Browser Support

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 CSSDescription top (cards 1, 2, 3)Footer top
Nested grid: grid-template-rows: auto auto 1fr26, 52, 131 px: misaligned49, 75, 153 px
grid-row: span 3; grid-template-rows: subgrid139, 139, 139 px: aligned169, 169, 169 px
grid-template-rows: subgrid without the span0, 0, 0 px: all three children overlap0, 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

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).

Frequently Asked Questions

What problem does subgrid solve?+
Nested grids can’t align with parent tracks without subgrid. It ensures card titles, descriptions, and footers align across a row of cards regardless of content length.
Can I use subgrid on both axes?+
Yes. Set grid-template-columns: subgrid and grid-template-rows: subgrid, and make the item span as many parent tracks as it has children on each axis, or its children will share one cell.
Is subgrid widely supported?+
Yes: Firefox 71, Safari 16, Chrome and Edge 117 (MDN compatibility data), about 94% of global usage per caniuse in October 2026. Older browsers ignore the value and give the item its own rows, so the layout degrades to unaligned rather than broken.
Try it yourself

Use the CSS Grid Generator β€” free, no signup required.

⚑ Open CSS Grid Generator
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.