Subgrid

suggest change

subgrid lets a nested grid reuse tracks defined by its parent. It is useful when repeated components need aligned internal rows:

<section class="cards">
  <article class="card">
    <h2>Short title</h2>
    <p>Longer summary text…</p>
    <a href="#">Read more</a>
  </article>
  <!-- More cards -->
</section>
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  grid-auto-rows: auto auto 1fr;
  gap: 1rem;
}

.card {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0;
}

.card > a {
  align-self: end;
}

Each card spans three parent rows and adopts those tracks as its own row grid, so titles, summaries, and links align across neighboring cards. Without subgrid, each nested grid sizes its rows independently.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents