"Grid isn't 'instead of' Flexbox. It's for what Flexbox forces you to fight."
The Six Patterns Grid Owns
Some layouts are technically possible in Flexbox with creative nesting, but Grid expresses them in a tiny fraction of the code. Recognize these and reach for Grid directly.
1. Overlapping Hero Content
A hero with a background image and text on top, in flow (no position: absolute). Place both in the same grid cell:
2. Full-Bleed Sections In A Constrained Layout
A long article with a max-width content column, where occasional images or quotes should span the full viewport width. Without Grid, this required nested wrappers; with Grid, define three columns (gutter / content / gutter), put everything in the middle column by default, and full-bleed items in column 1 / -1:
3. Magazine-Style Asymmetric Columns
A layout where some items span 2 columns, some span 3, some span the full width — and the rows align across the page. Grid's grid-column: span N handles this natively:
4. Dashboard With Variable Tile Sizes
Stats tiles where some are 1x1 (small KPI), some are 2x1 (charts), some are 2x2 (big map). Grid with span and dense packing fills the dashboard with no gaps:
5. Cross-Card Alignment With subgrid
Card grid where every card has a title, an image, and a footer — and you want all titles to align horizontally even if their text lengths differ:
6. Photo Gallery With Variable Aspect Ratios
A photo grid where photos have different sizes (wide landscape, tall portrait), packed efficiently:
What Grid Doesn't Do (And Flexbox Does)
- Distribute space evenly with content-aware sizing. Flexbox's
flex: 1+ content sizes does this naturally. Grid columns are defined upfront. - Wrap items of unpredictable widths. Flexbox
flex-wrapwraps as needed; Grid wraps into a defined column structure. - Single-axis arrangements. Flexbox is simpler for navbars, button rows, single columns. Grid for those is overkill.
If your mental model is "a row of N items that should adapt their widths based on content," Flexbox. If your mental model is "items snap into a coordinate system I designed," Grid.
The Decision Heuristic
- Is it page-level structure? (Header, sidebar, main, footer) → Grid with template-areas.
- Is it a tile grid with possibly variable sizes? → Grid with span/dense.
- Do items need to align across cells in both axes? → Grid (with subgrid for nested alignment).
- Do items overlap or need cell-precise placement? → Grid.
- Else? → Flexbox.