Observation Guide

DevTools for layout

WhereUse
Elements → Layout panetoggle grid/flex overlays; shows line numbers, areas, gaps
Grid overlay badgesthe grid/flex badge next to an element in Elements
Performance → Layout blocksduration and "Nodes That Need Layout: N of M"
Performance → red triangleforced synchronous layout, with the causing stack
Rendering → Layout Shift Regionswhat moved; the CLS diagnostic
Elements → Computed → containerwhich ancestor a container query resolves against

"Nodes That Need Layout: 12 of 40,000" remains the most useful single number. A high ratio for a local change means containment is missing (fe-05), not that the layout mode is wrong.

Debugging container queries

Three failures account for most container-query bugs:

  1. No container. @container with no ancestor carrying container-type never matches. Check Computed → container-type on ancestors.
  2. Wrong container. Queries resolve against the nearest qualifying ancestor. A nested query container silently intercepts. Name them (container-name) and query by name in shared code.
  3. Container sized by its contents. container-type: inline-size means the inline size may not depend on contents. A fit-content or floated wrapper will change behaviour when it becomes a container — this reads as "adding container-type broke my layout", and it is the containment promise being enforced.

Debugging flex and grid

SymptomCause
Flex item will not shrink below its contentmin-width: automin-content. Fix: min-width: 0
Grid item overflows its tracksame, on min-width/min-height
justify-content does nothingitems already fill the line; you probably want flex: 1 or justify-items
Gap ignorednot a flex/grid container, or using an old multicol context
Nested content will not align across cardsneeds subgrid; the usual workaround is fixed heights, which breaks under long strings

The min-width: auto default is the single most common flex/grid confusion and worth internalising: flex and grid items refuse to shrink below their content by default.

What these measurements do not tell you

  • No paint or compositing cost measured. RecalcStyleDuration and LayoutDuration only.
  • Headless is not headed for compositing; these numbers are style/layout, which are less affected, but do not extend them.
  • Synthetic uniform content. Real layouts mix images, fonts, and nested components with their own intrinsic sizing, which changes the measurement burden.
  • One viewport. Every result depends on available width.
  • No layout thrash here. fe-01 measured 98× from interleaved reads and writes; that dominates everything in this module and is invisible to these experiments by construction.