Shared Furrows: Subgrid Layouts Without the Wrapper Weeds
Photo: Cryonic07, CC BY-SA 3.0, via Wikimedia Commons
Wrapper divs are the bamboo cane of CSS layout: useful, cheap, and easy to leave in the ground until the whole bed is a thicket. Subgrid offers a way to share a track structure across components without building a scaffolding tower around every card, form row, or caption.
The idea is straightforward. A grid item can opt into its parent's row or column tracks with grid-template-columns: subgrid or grid-template-rows: subgrid. Instead of redefining the same columns and rows inside each component, the component inherits the parent's furrows. That makes alignment a shared decision rather than a collection of local guesses.
What subgrid actually shares
Subgrid does not copy a grid. It lets a nested grid participate in the parent's tracks. If the parent has three columns and the child spans all three, the child can use grid-template-columns: subgrid so its own children line up with those three columns. The same works for rows.
That is useful when alignment matters across components: a row of charity campaign cards where every title and button should sit on the same line, a council form where labels and controls should share a column, or a gallery where captions should start at the same height.
The accessibility angle is not decorative. Fewer wrapper divs means a cleaner DOM, but only if the remaining elements still make sense. Do not remove semantic elements just because subgrid can replace a layout wrapper. A fieldset, label, figure, and figcaption are doing real work. Keep them.
Card grids: titles and actions on the same furrow
Picture a charity campaign page with three appeal cards. Each card has an eyebrow, a title, a short description, and a donation link. Without subgrid, you either accept ragged alignment or wrap every part in extra containers and use flexbox tricks.
With subgrid, the parent defines the shared rows, and each card inherits them:
.card-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-rows: auto auto 1fr auto;
gap: 1.5rem;
}
.card {
display: grid;
grid-row: span 4;
grid-template-rows: subgrid;
gap: 0.75rem;
}
The card's children flow into the shared rows. The eyebrow, title, description, and action all line up across the three cards because they are using the parent's row tracks, not their own. The 1fr row gives the description room to breathe while keeping the action anchored to the bottom.
Use minmax(0, 1fr) rather than 1fr for columns when cards contain long words or links. It prevents the grid from refusing to shrink below the content's minimum size, which is a common cause of horizontal overflow on narrow screens.
Form rows: labels and controls on shared lines
Public-service forms are a good test because they are repetitive and unforgiving. A bulky waste collection form, a school place application, or a village hall booking form all need labels, controls, and hints to line up without becoming a table.
Subgrid can make the form row share the form's columns:
.booking-form {
display: grid;
grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
gap: 0.75rem 1rem;
}
.field {
display: grid;
grid-column: 1 / -1;
grid-template-columns: subgrid;
}
.field label {
grid-column: 1;
}
.field input,
.field select,
.field .hint {
grid-column: 2;
}
Each field spans both columns and then subgrids them. Labels sit in the first column, controls and hints in the second. The DOM stays simple: a label, an input, and a hint. No extra row wrappers, no presentational divs between the label and its control.
That matters for accessibility. Keep the for attribute and the id pairing intact. Do not rely on visual proximity alone. Subgrid is a layout tool, not a labelling mechanism.
Captions: a shared baseline across a page
Galleries often suffer from caption drift. One image is portrait, another is landscape, and the captions end up scattered like seed packets after a gust of wind. Subgrid can give the figures shared rows:
.gallery {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-rows: auto auto;
gap: 1rem;
}
.gallery figure {
display: grid;
grid-row: span 2;
grid-template-rows: subgrid;
margin: 0;
}
.gallery img {
width: 100%;
height: 100%;
object-fit: cover;
}
.gallery figcaption {
align-self: start;
}
The image occupies the first shared row, the caption the second. Across the gallery, captions begin at the same height even when the images have different aspect ratios. The figure and figcaption elements remain intact, so screen readers still get the relationship between image and caption.
When subgrid is not the answer
Subgrid is excellent for shared alignment. It is less useful when the parent grid is highly dynamic, when only one component needs the alignment, or when the fallback would be more complex than the original wrapper. It also does not solve every responsive layout problem. Sometimes a simple flex column with margin-block-start: auto on the action is clearer and more robust.
If you are supporting browsers without subgrid, write the fallback first. For cards, that might mean a flex column with the action pushed to the bottom. For forms, it might mean a two-column grid declared directly on each field. Then wrap the subgrid enhancement in a feature query:
@supports (grid-template-columns: subgrid) {
.booking-form {
grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
}
.field {
grid-template-columns: subgrid;
}
}
The fallback should not be a broken version of the enhanced layout. It should be a complete, usable layout that happens to be less precisely aligned.
Keep the bed readable
The real win with subgrid is not fewer divs for their own sake. It is a DOM that reflects the content, with alignment handled by the grid rather than by a pile of layout-only containers. Use it where shared tracks genuinely help: repeated cards, form rows, and captions. Leave the wrapper in place when it carries meaning. A tidy allotment is not one with no canes; it is one where every cane is doing a job.