Cumulative Layout Shift (CLS): How to Find and Fix Unexpected Page Movement
How layout shift is scored, what a session window is, which shifts do not count, and how to reserve space for everything that arrives late.
In short
Cumulative Layout Shift scores how much your page moves about while it loads. Google wants a score of 0.1 or less for at least three quarters of your visitors.
It is the most fixable of the three Core Web Vitals, because the cause is nearly always the same: something arrived late and pushed existing content out of the way. An image with no reserved space, a font that changed the size of your text, a banner inserted above the page, an advert that expanded.
The fix is nearly always the same too: tell the browser how much room something needs before it arrives, so the space is already waiting.
Why layout shift matters more than it sounds
A score is an abstract thing, so here is the concrete version. A visitor goes to tap "Add to cart". In the instant before their finger lands, an image above finishes loading, everything moves down, and they tap "Subscribe to newsletter" instead.
That is what CLS measures: not ugliness, but a page that moves under people's hands. It is a usability failure, and on a checkout it is a revenue failure.
It also affects reading. Text that jumps while someone is reading a line makes them lose their place, which is a small, constant irritation that people experience as the site being badly made.
How the score is calculated
Most articles skip this, and it is worth understanding, because it explains why one bad shift can ruin your score while many tiny ones do not.
Each shift is scored by multiplying two fractions:
Impact fraction — how much of the visible screen was affected. If content filling half the viewport moves, the impact fraction is 0.5.
Distance fraction — how far it moved, as a proportion of the viewport. Content that moves 10% of the screen height has a distance fraction of 0.1.
A block covering half the screen that moves down by 10% of the screen scores 0.5 × 0.1 = 0.05.
So a large element moving a short way scores about the same as a small element moving a long way. Unit-less, which is why CLS has no "seconds" or "milliseconds".
Session windows — why your worst moment is what counts
CLS does not add up every shift over the whole visit. It groups shifts into session windows: a window opens at the first shift, extends while shifts keep happening within one second of each other, and closes after five seconds at most.
Your CLS is the score of the worst window, not the total.
This has a practical consequence. A page that shifts slightly on a continuous basis as the visitor scrolls may score better than a page with one dramatic shift during load. Fix the dramatic one first.
Shifts that do not count
A shift within 500 milliseconds of a user interaction is excluded. Opening a menu, expanding an accordion, revealing a dropdown — all expected, all ignored by the metric.
This is the difference between an unexpected layout shift and a response to something the visitor did. If content moves because someone asked it to, that is not a CLS problem.
What causes it, in order of how often we see it
Images and video without dimensions. The browser cannot reserve space for something whose size it does not know, so it reserves none, and everything jumps when the file arrives. By far the most common cause.
Web fonts. Text renders in a fallback font first, then swaps. If the two fonts have different letter widths and line heights, every line of text changes size and position at the swap.
Content inserted above existing content. Cookie notices, promotional bars, "free shipping" banners, app-injected announcements. The worst version is a banner inserted at the very top of the document after the page has rendered: everything on the page moves down at once.
Adverts and embeds. Third-party iframes that do not know their own size until they load, and sometimes resize afterwards.
Components that resize after loading. A review widget that starts at zero height and expands. A product grid that reflows once prices arrive from an API. A carousel that changes height between slides.
Animating the wrong properties. Animating height, width, top or margin causes layout to be recalculated on every frame. Animating transform and opacity does not.
Lazy loading applied to in-viewport content, which arrives late by design and therefore shifts late.
How to find your shifts
Step 1 — field data tells you whether you have a problem
PageSpeed Insights shows your real-user CLS. Search Console groups affected URLs, which tells you whether it is one page or a shared template.
Step 2 — see the shifts happen
The quickest way to actually watch them:
- Open your page in Chrome, open DevTools.
- Press Ctrl+Shift+P and run Show Rendering.
- Tick Layout Shift Regions.
- Reload with throttling on.
What you should see: affected areas flash a translucent blue at the moment they move. This is the fastest way to find which element is responsible, and it is worth doing before any measurement.
Step 3 — measure and attribute them
- DevTools → Performance, set network to Slow 4G, record a reload.
- Find the Layout Shifts track.
- Click a shift. The summary names the score, and the affected nodes.
What you should see: each shift with its score, and the element that moved. Add the scores in the worst window and you have your CLS.
Step 4 — check it on a phone-sized viewport
Mobile layouts stack differently, and a shift that does not exist on desktop can be severe on mobile. Test both.
How to fix each cause
Images and video
Put the real intrinsic dimensions on the element. You still control the displayed size with CSS — the attributes just let the browser work out the aspect ratio and reserve the right box.
<!-- The browser reserves a 3:2 box at whatever width the CSS gives it. -->
<img src="/product.webp" width="1200" height="800" alt="..." style="width: 100%; height: auto">
If you cannot set attributes — some page builders strip them — use CSS instead:
.product-image { aspect-ratio: 3 / 2; width: 100%; height: auto; }
For video, set dimensions on the element and provide a poster.
You can see this working, with the shift and without it, in the layout shift demo in our performance lab — two pages differing only in those two attributes.
Web fonts
Two parts. First, stop text being invisible:
@font-face {
font-family: 'Brand';
src: url('/fonts/brand.woff2') format('woff2');
font-display: swap;
}
swap renders immediately in the fallback — good for perceived speed, but it is the swap itself that shifts layout. So second, make the fallback match the real font's metrics:
@font-face {
font-family: 'Brand fallback';
src: local('Arial');
size-adjust: 97%;
ascent-override: 90%;
descent-override: 22%;
line-gap-override: 0%;
}
body { font-family: 'Brand', 'Brand fallback', sans-serif; }
Tune the percentages until the swap is visually imperceptible — the full method is in web font optimization. Preloading the font helps too, by shortening the window in which the fallback is shown.
Banners, notices and injected content
Reserve the space, or do not push. Either give the banner a fixed height that is always present, or position it so it overlays rather than displaces — position: fixed or sticky does not move anything.
/* Reserved, so nothing moves when the notice appears. */
.announcement-slot { min-height: 44px; }
Never insert content at the top of the document after render without reserved space. That is the single most damaging CLS pattern there is.
Adverts and embeds
Reserve the largest size the slot can take, and avoid collapsing the slot when nothing fills it — an empty reserved box is better than a page that jumps.
Components that load their own content
Give the container a min-height matching its typical filled size, or show a skeleton occupying the same space as the real content.
Animation
Animate transform and opacity. Both are handled by the compositor, do not trigger layout, and are not counted as layout shift.
/* Causes layout shift */
.panel { transition: height 0.3s; }
/* Does not */
.panel { transition: transform 0.3s, opacity 0.3s; }
Platform differences
Shopify. Use image_tag, which emits width and height for you — many CLS problems on Shopify come from hand-written <img> tags that skip them. Announcement bars and app-injected banners are the other usual cause: check whether an app inserts content above the fold after load. Theme section ordering matters too, since anything that appears above the hero displaces it.
WordPress and WooCommerce. WordPress adds image dimensions automatically in most cases, so the usual culprits are page builders that strip them, sliders that initialise in JavaScript, and plugins that inject notices. Check the rendered HTML of a real page rather than assuming.
Custom and headless builds. Client-side rendered content is the main risk: if the layout is only known after data arrives, the page will shift. Reserve space with skeletons sized to the real content, and server-render where you can.
Hosted builders. Image dimensions are usually handled by the platform. Your remaining risks are the apps and custom code you add, and anything you place above the fold.
Common mistakes
Fixing shifts that do not count — anything within 500 ms of an interaction is already excluded.
Setting dimensions that do not match the real aspect ratio, which reserves the wrong box and shifts anyway.
Using font-display: block to avoid the swap shift. You have traded a shift for invisible text, which is worse.
Reserving space with a fixed height and squashing the content, instead of using min-height or aspect-ratio.
Testing only on desktop. Mobile layouts stack, so the same late element displaces far more.
Testing only with a warm cache. Everything is already loaded, so nothing shifts and the problem looks solved.
Assuming a perfect lab score means a passing field score. A lab run loads the page once, scrolls nothing, and interacts with nothing. Real visitors scroll into lazy-loaded content and trigger shifts a lab run never sees.
Verification
- Watch it with Layout Shift Regions on. The flash should be gone. This is the most direct confirmation available.
- Re-record and confirm the shift is absent from the Layout Shifts track, and that your CLS is lower.
- Scroll the whole page while recording. Shifts further down only happen when content there loads.
- Check mobile and desktop.
- Check with an empty cache, since a warm cache hides the problem.
- Confirm you did not damage LCP. Reserving space is free; preloading fonts to shorten the swap window is not, and competes with your LCP image.
- Wait for field data — the rolling 28-day window means roughly a week before movement and four before it settles.
When it still does not improve
- The lab says 0, the field does not — lab runs do not scroll or interact. Your shifts are probably below the fold, or triggered by something only real visitors do.
- A shift you cannot attribute to any of your own elements — it is likely a third-party script or app injecting content. Disable them one at a time in a staging copy.
- It only happens sometimes — a race condition: the shift occurs only when a resource is slow enough to arrive after render. Throttle harder to reproduce it reliably.
- Fonts still shift after metric overrides — the fallback is still not matching. Adjust
size-adjustin small steps and compare screenshots at the moment of swap. - An advert slot still shifts — the network is returning a creative larger than your reserved size. Reserve the largest permitted size.
Keeping CLS good
CLS is the Core Web Vital most often broken by people who are not developers: a new promotional bar, a new app, a review widget, an image uploaded without dimensions through a CMS that does not add them.
Three habits keep it fixed: make width and height non-negotiable wherever images are added, reserve a permanent slot for anything that may be injected above the fold, and check layout stability before a release rather than after someone complains that the page jumps.
Frequently asked questions
What is a good CLS score?
0.1 or less for at least 75% of visits. Between 0.1 and 0.25 needs improvement, and over 0.25 is poor. CLS has no unit — it is a score from how much of the screen moved multiplied by how far it moved.
How do I fix layout shift on my website?
In most cases, add width and height attributes to every image, or an equivalent CSS aspect-ratio. Then reserve permanent space for anything injected above the fold, such as a cookie notice or promotional bar, and match your fallback font’s metrics to your web font so the swap does not resize text.
Does CLS include shifts caused by clicking something?
No. Shifts within 500 milliseconds of a user interaction are excluded, so opening a menu or expanding an accordion does not count. Only unexpected movement is scored, which is why some shifts flagged in a lab run do not affect your field score at all.
Why is my CLS zero in testing but bad in Search Console?
A lab test loads the page once, does not scroll, and does not interact. Real visitors scroll into lazy-loaded content and trigger shifts a lab run never reaches. Record a session while scrolling the whole page to find them.
Do web fonts cause layout shift?
They can. Text renders in a fallback font first and then swaps to yours. If the two fonts have different letter widths and line heights, every line resizes at the swap. Fix it by matching the fallback metrics with size-adjust and the ascent and descent overrides.
Is CLS only about images?
No, though images are the most common cause. Web fonts, cookie banners, adverts, embeds, late-loading review widgets and animating layout properties such as height all cause shift.
References
- Cumulative Layout Shift (CLS) — web.dev
- Optimize Cumulative Layout Shift — web.dev
- Debug layout shifts — Chrome DevTools
- aspect-ratio — MDN
- font-display — MDN