---
title: "Subgrid: how to line up elements to your heart’s content"
description: "CSS subgrid lets nested grid items adopt the row or column tracks defined on a parent grid, so content inside sibling cards stays aligned even when one card has longer text."
url: "https://swe.quest/articles/subgrid-how-to-line-up-elements-to-your-heart-s-content-a1a2b0f9110769af"
canonical: "https://webkit.org/blog/17339/subgrid-how-to-line-up-elements-to-your-hearts-content/"
source: "WebKit"
published: "2025-09-12"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["css","frontend"]
---

# Subgrid: how to line up elements to your heart’s content

A post on [WebKit](https://swe.quest/sources/webkit.md), published 2025-09-12, 4 min read, How-to. Original: [https://webkit.org/blog/17339/subgrid-how-to-line-up-elements-to-your-hearts-content/](https://webkit.org/blog/17339/subgrid-how-to-line-up-elements-to-your-hearts-content/)

## Summary

CSS subgrid lets nested grid items adopt the row or column tracks defined on a parent grid, so content inside sibling cards stays aligned even when one card has longer text. A pricing-page walkthrough shows the three steps: make each card a grid, set grid-template-rows: subgrid, define matching rows on the parent (grid-template-rows: repeat(4, auto)), and have each card span them with grid-row: span 4. Skipping the span collapses all card content onto one row. Subgrid is supported across major browsers and safe to use.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [CSS](https://swe.quest/tags/css.md) (Web & mobile)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)

## Prerequisites

- CSS Grid basics ([easy posts on CSS](https://swe.quest/tags/css.md?difficulty=easy))

## Keywords

CSS Subgrid, CSS Grid, WebKit

## Related posts

- [Help us invent CSS Grid Level 3, aka “Masonry” layout](https://swe.quest/articles/help-us-invent-css-grid-level-3-aka-masonry-layout-ed399042099ed6d0.md): WebKit · 2024-04-19 · Medium · 19 min read · CSS, Browsers, Frontend
  CSS Grid Level 3, often called masonry or waterfall layout, adds \`grid-template-rows: masonry\` so content packs into columns without rows, with no JavaScript and no cropping.
- [CSS Grid: A helpful mental model and the power of grid lines](https://swe.quest/articles/css-grid-a-helpful-mental-model-and-the-power-of-grid-lines-4d5050e2d975310a.md): WebKit · 2025-10-10 · Medium · 9 min read · CSS, Frontend
  CSS Grid becomes easier to reason about when a layout starts from the container, treated like a spreadsheet whose columns and rows are defined before content is placed.
- [Grid: how grid-template-areas offer a visual solution for your code](https://swe.quest/articles/grid-how-grid-template-areas-offer-a-visual-solution-for-your-code-81a307f52b1b6dda.md): WebKit · 2025-11-21 · Medium · 3 min read · CSS, Frontend
  CSS Grid's grid-template-areas lets you place elements by naming them with the grid-area property and then drawing the layout as rows of quoted strings, where repeating a name across cells makes an element span rows or columns.
- [When will CSS Grid Lanes arrive? How long until we can use it?](https://swe.quest/articles/when-will-css-grid-lanes-arrive-how-long-until-we-can-use-it-0440c8888ab4100c.md): WebKit · 2026-01-22 · Medium · 12 min read · CSS, Browsers, Frontend
  CSS Grid Lanes, the masonry-style layout from CSS Grid Level 3, ships with its finalized \`display: grid-lanes\` syntax in Safari Technology Preview.
- [Introducing CSS Grid Lanes](https://swe.quest/articles/introducing-css-grid-lanes-2d3c264610a9740d.md): WebKit · 2025-12-19 · Medium · 8 min read · CSS, Browsers, Frontend, Accessibility
  CSS Grid Lanes (\`display: grid-lanes\`) brings native masonry layouts to the web, available in Safari Technology Preview 234.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
