Cumulative Layout Shift (CLS): fixes
What Cumulative Layout Shift measures, the 0.1 and 0.25 thresholds, and the usual causes from images to ads, with the fix for each from web.dev.
· Updated · 5 min read

Cumulative Layout Shift (CLS) measures how much visible content moves unexpectedly while a page loads and while you use it. A page is good at 0.1 or less and poor above 0.25, measured at the 75th percentile of page loads, split by mobile and desktop. web.dev's guide covers images without dimensions, ads and other late-loaded content, injected content, animations and web fonts, and adds the back and forward cache as a way to avoid repeating load-time shifts.
This guide follows web.dev's CLS article and its guide to optimizing CLS. Where I say what I do on this site, I mark it as mine.
What the number means#
web.dev defines CLS as a measure of the largest burst of layout shift scores for every unexpected layout shift over the lifetime of a page. Each shift has a score:
layout shift score = impact fraction × distance fraction
The impact fraction is the share of the viewport affected by the elements that moved, across two frames. The distance fraction is the largest distance an element moved, divided by the larger dimension of the viewport.
Shifts are grouped into bursts, called session windows. A window holds shifts with less than a second between them, up to five seconds in total, and CLS is the score of the window with the highest total. Shifts within 500 milliseconds of a click, a tap or a key press are flagged as caused by the user and can be excluded. Scrolling, dragging and pinch zoom do not count as input for that rule.
| Rating | CLS at the 75th percentile |
|---|---|
| Good | 0.1 or less |
| Needs improvement | between 0.1 and 0.25 |
| Poor | above 0.25 |
1. Images and video without dimensions#
The browser does not know how much space to reserve, so content below jumps when the media arrives. web.dev's advice is to always include width and height attributes on images and video, because modern browsers use them to work out a default aspect ratio. CSS aspect-ratio also reserves space.
<img src="puppy.jpg" width="640" height="360" alt="A puppy on a lawn" />
img {
height: auto;
width: 100%;
}
For responsive images, keep the same aspect ratio across all the srcset variants. My blog covers use this pattern: every cover img has width="1200" and height="630", so the space is reserved before the file loads.
2. Ads, embeds and iframes#
web.dev says ads are one of the largest contributors to layout shift on the web. A late-loading slot pushes content down. Its fixes:
- Reserve space with
min-height, oraspect-ratiofor responsive slots. - Reserve the smallest size you expect. A larger ad then causes less shift than one that arrives in an empty container.
- Keep a placeholder if no ad comes back, because removing reserved space causes as much shift as adding content.
- Place late-loading content lower in the viewport, where an injection moves less.
If you reserve display ad slots, you need the real dimensions. The Banner Sizes tool lists the common sizes with their ratios and which ones Google Ads accepts.
3. Dynamically injected content#
Banners, cookie notices, forms and feed updates shift the page when they are inserted without reserved space. The guide suggests a placeholder or a skeleton, or an overlay that leaves the document flow. You can also swap content inside a container of fixed size, or load new content only after a user action such as a "Load more" button. Because shifts within 500 ms of an input are excluded, an action-triggered load is safer, though a slow fetch should still reserve the expected space.
4. Web fonts#
Both a flash of unstyled text and a flash of invisible text re-lay out the text when the web font arrives, so both can cause a shift. The guide lists these fixes:
font-display: optionalavoids the re-layout, because the web font is used only if it is ready at first layout.- A close fallback font in the
font-familylist keeps the change small. size-adjust,ascent-override,descent-overrideandline-gap-overridetune the fallback's metrics to match the web font.<link rel="preload">for the critical fonts helps them arrive in time.
5. Animations#
Animating top and left triggers layout and can shift the page. Move things with transform instead. web.dev says composited translate animations do not count toward CLS.
.panel {
transform: translateY(0);
transition: transform 0.3s;
}
This is also why the page transition on this site uses only transform properties (translate, scale) and opacity. For more on how long such animations should last, see How long should a UI animation take?.
6. Avoiding repeat shifts: the back and forward cache#
Returning to a page can repeat its load-time shifts. When a page is eligible for the back and forward cache, the browser restores it as it was left, so the fully loaded page appears at once without new shifts. The guide points to its bfcache article to check what makes a page ineligible.
Measuring it#
For lab data, use Lighthouse's CLS audit and the Layout Shifts track in the DevTools Performance panel. For field data, use the web-vitals attribution build or a real-user monitoring tool. web.dev notes that a large gap between CrUX and Lighthouse numbers usually means shifts happen after load.
On this blog, Lighthouse reports a CLS of 0 on every post I tested. That is a lab number from one machine. I have not measured CLS from real visits.
One more habit that helps#
The site sets scrollbar-gutter: stable on the page, which keeps room for the scrollbar so the layout does not jump when a loader locks scrolling and the scrollbar disappears. That is my own rule for this site and not from the web.dev guide, and it addresses one specific shift. It does nothing for the causes above.
Limits of this guide#
The thresholds and fixes come from web.dev's articles, which I read on 18 October 2026. I did not test each fix on a page of my own. The CLS of 0 I mention is from lab runs on a local build.