Start with the mechanism
Understand the failure before changing CSS
Layout shift is an observed movement, not a single implementation mistake. Images can acquire dimensions after a response arrives, font substitution can change line metrics, and delayed banners or third-party slots can be inserted without reserved space. The common investigation question is what changed geometry after the initial layout and which component was responsible for allocating that space.
Use geometric movement as the cross-browser baseline and treat Layout Instability API entries as additional evidence only where supported. A zero score does not prove that nothing moved if the browser did not expose the API entry, recent input excluded it, or the measurement watched the wrong target. Preserve before and after rectangles, timing, focus state, and the exact insertion or substitution event.
Decision routes
Choose the route that matches the measured signal
These branches describe different ownership boundaries. Follow the signal that matches the page, then open the linked fixture to compare a controlled failure with its smallest verified correction.
Image dimensions arrive after layout
- Visible signal
- Content below an image moves when the image source becomes available, especially on a cold load or slower connection.
- Likely mechanism
- The browser cannot reserve the final aspect-ratio box before intrinsic dimensions or an equivalent ratio are known.
- Next measurement
- Provide valid width and height attributes or an authored aspect ratio, then verify the rendered size remains responsive.
Font substitution changes line geometry
- Visible signal
- Text rewraps or changes height when the final font replaces the initial metrics.
- Likely mechanism
- Fallback and final glyph metrics produce different line breaks and block dimensions.
- Next measurement
- Measure the text and following target before and after substitution. Improve loading and metric compatibility without claiming one universal font strategy.
Delayed embed or ad slot starts at zero height
- Visible signal
- An empty region later receives content and pushes the article below it, even though the inserted asset itself has stable dimensions.
- Likely mechanism
- The owning slot did not declare space before asynchronous content arrived.
- Next measurement
- Reserve a reviewed slot size or aspect ratio based on actual supported formats, and define behavior when no content is returned.
Consent or notification interface is inserted into flow
- Visible signal
- A notice appears after initial render and moves the active task, or an overlay avoids movement but obscures content and focus.
- Likely mechanism
- The interface changes normal-flow geometry without a prepared region, or leaves normal flow and creates an obstruction instead.
- Next measurement
- Choose a real production interaction model, reserve or overlay deliberately, and test geometry together with keyboard focus restoration.
Numbers before conclusions
Measurement reference
Use the same measurements before and after a change. A fix is credible when it improves the intended boundary without making content or controls less reachable.
Record a stable target top coordinate immediately before and after the controlled late event.
The fixed state keeps the target coordinate stable unless movement is an intentional response to user input.
Compare the slot, image, or notice region before loading with the final rendered width, height, and aspect ratio.
The initial reservation matches every supported final format closely enough to prevent unintended downstream movement.
Record when insertion or substitution occurs, whether recent input preceded it, and which element owns focus afterward.
Geometry evidence can be tied to one reproducible event and keyboard continuity is preserved through the update.
Repeatable method
Inspection workflow
- 01
Choose a stable target below the event
Measure an element whose movement represents user-visible disruption, not only the late-loading element itself.
Keep: Record the target selector and its top coordinate before the event.
- 02
Control the late event
Use a deterministic delayed image, font substitution, slot insertion, or notice insertion so repeated runs describe the same mechanism.
Keep: Record fixture version, delay trigger, and the state before insertion or substitution.
- 03
Measure geometry before and after
Capture subject height, reserved region height, target position, and resulting movement. Collect Layout Instability API entries only as a supported supplement.
Keep: Keep the movement in CSS pixels and disclose browser API coverage.
- 04
Assign space to the owning component
Provide intrinsic image dimensions, improve font metric behavior, reserve a delayed slot, or define the notice region and focus path. Avoid unrelated page-wide minimum heights.
Keep: The fixed state should preserve the same content and event while eliminating unintended target movement.
- 05
Test real content variants
Check responsive image sizes, font fallback conditions, supported slot formats, translated consent text, and empty or failed asynchronous responses.
Keep: Document which variants were tested and which remain outside the conclusion.
What controlled fixtures reveal
Field notes
These details are easy to miss when a page is checked at only one width or with idealized content. They turn the guide into a repeatable review rather than a one-off patch.
Test cold and warm paths
Cached images or fonts may arrive too quickly to expose the first-load geometry change seen by a new visitor.
Apply: Keep a deterministic delayed fixture and separately verify the optimized cached path does not introduce a different state.
Treat API data as supplemental
Layout Instability entries depend on browser support and eligibility rules, while element rectangles remain broadly measurable.
Apply: Store geometric before-and-after evidence in every browser and attach API entries only where the runtime reports them.
Define empty and failure states
A reserved slot can leave unexplained blank space when an asset, ad, or remote response never arrives.
Apply: Specify when the reservation collapses, what replaces it, and how that transition affects movement and focus.
Do not trade one defect for another
Common misfixes
Hide movement with animation
A transition can make motion look smoother while the target still changes position and may remain disruptive or inaccessible.
Use instead: Reserve stable geometry first; use motion only when it serves the interaction and respects reduced-motion preferences.
Move every late element to a fixed overlay
Removing an element from flow can trade layout movement for content obstruction, focus loss, or an unusable mobile viewport.
Use instead: Evaluate insertion and overlay models against both geometry and keyboard access.
Use one arbitrary min-height for all variants
The value may waste space for small content and still fail for translated text, alternate ad formats, or narrow layouts.
Use instead: Reserve space from a controlled format contract and test each supported size or content state.
Treat one API score as the entire result
API support and entry eligibility vary, while real target geometry can still move.
Use instead: Keep before-and-after rectangles as the common baseline and label API data by browser.
Before publishing the component
Release checks
- Images provide valid intrinsic dimensions or an equivalent reserved aspect ratio.
- Font loading and fallback behavior have been tested with representative text.
- Delayed slots reserve only reviewed formats and define empty-state behavior.
- Consent and notification interfaces preserve both geometry and keyboard continuity.
- Movement is recorded geometrically across browsers, with API limits disclosed.
- The fixed state retains the same late event rather than removing the tested content.
Project-owned fixtures
Verified Layout Shift cases
Each case includes a failing and fixed fixture, exact CSS or script diff, current-browser measurements, and a three-browser evidence manifest.
Prevent Image Layout Shifts With Width and Height
A project-owned image receives its source after initial layout; without dimensions the following content moves when the image becomes available, while width and height reserve its aspect ratio in advance.
Measure and Reduce Layout Shift From Web Font Substitution
A deterministic system-font model isolates the geometry change caused by swapping fonts with different metrics, then compares it with making the final face available before the first measured layout.
Reserve Stable Space for Ads and Third-Party Embeds
A project-authored delayed panel shows how inserting unknown content into a zero-height slot moves the article below it, while an initial minimum height preserves layout.
Add a Cookie Banner Without Shifting or Obscuring Content
A project-authored consent notice compares unreserved insertion with a stable region, then verifies that keyboard dismissal removes the notice and returns focus to the prior control.
Source boundary
Primary references used by these cases
The guide summarizes project measurements. Normative behavior and accessibility requirements remain linked to the primary sources reviewed for each case.
- Optimize Cumulative Layout Shift - images without dimensionsGoogle web.dev · checked 2026-08-06
- HTML Standard - presentational hints for width and heightWHATWG · checked 2026-08-04
- Layout Instability APIWeb Platform Incubator Community Group · checked 2026-08-04
- CSS Fonts Module Level 5 - font metric overridesW3C · checked 2026-08-04
- Best practices for fontsGoogle web.dev · checked 2026-08-04
- Optimize Cumulative Layout Shift - web fontsGoogle web.dev · checked 2026-08-06
- Optimize Cumulative Layout Shift - ads, embeds, and late-loaded contentGoogle web.dev · checked 2026-08-06
- Understanding Focus Not Obscured (Minimum)W3C Web Accessibility Initiative · checked 2026-08-04
- Understanding Focus OrderW3C Web Accessibility Initiative · checked 2026-08-04
