liveBook · Manning

Subgrid

As explained in CSS in Depth, Second Edition

Subgrid is a CSS Grid feature that lets a nested grid use the grid lines of its parent grid for its rows, columns, or both.

Subgrid lets a nested grid position its rows, columns, or both on the grid lines of its parent. This solves alignment problems that span multiple levels of markup. section 5.5 section 5.7

Aligning author cards

A three-column author-card layout can align each heading, paragraph, and Read More link across every card. Make each card a grid, let it span three parent rows, and inherit those rows with grid-template-rows: subgrid. Short headings then receive space above them, paragraphs begin at the same height, and links align along the bottom.

Subgrid also supports these placement techniques:

  • Inherited line numbers, line names, and area names can place items within the subgrid; grid-row: 2 places every card title on the second row. section 5.5.1
  • Additional line names can be assigned after the subgrid keyword, such as subgrid [line1] [line2] [line3] [line4]. section 5.5.1
  • Use browser grid debugging tools to inspect lines and gaps; support is newer and varies by browser. section 5.5

How CSS in Depth, Second Edition covers it

How deep it goes
Explains the alignment principle, builds an author-card layout, demonstrates named lines, and notes browser support without detailing rendering internals.
Examples
Uses three author cards whose headings, paragraphs, and Read More links align across shared rows.
What it assumes
Assumes familiarity with CSS Grid rows, columns, gaps, and grid placement while demonstrating the nested alignment problem concretely.
What you can do after
Build it from scratch by nesting grids, spanning parent tracks, inheriting them with subgrid, and placing items on inherited or named lines.
How it connects
Connects CSS Grid, grid lines, grid areas, flexbox, and browser developer tools.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.