How to Fix Cumulative Layout Shift (CLS) on Your Website
Cumulative Layout Shift (CLS) measures how much visible content jumps around while a page loads and while people use it. This guide shows you how to find the elements that move, reserve space for them, and bring your PageSpeed Insights CLS score below 0.1.

Why it matters
CLS is one of Google's three Core Web Vitals. 25 or higher. Layout shifts also cause misclicks on buttons and ads, lost reading position and abandoned checkouts, especially on mobile.
Our audit reads CLS from PageSpeed Insights, using real-user field data when Google has it and lab data otherwise. 25 or higher fails.
What you need
Step-by-step fix
Measure CLS and find the shifting elements
Run your URL at pagespeed.web.dev and note two things: the CLS value, and whether it comes from field data (real Chrome users over 28 days) or lab data (one simulated load). Open the Diagnostics section and expand Avoid large layout shifts to see which elements moved. Then check the page in Chrome itself:
- Open DevTools and go to the Performance panel.
- Record a page reload.
- Look at the Layout shifts track. Purple markers show each shifted node.
Shifts caused by scrolling or by late interactions only show up in field data. To capture those from real visitors, log attribution with the web-vitals library.
<script type="module">
import {onCLS} from 'https://unpkg.com/web-vitals@4/dist/web-vitals.attribution.js?module';
onCLS(({value, attribution}) => {
console.log('CLS', value.toFixed(3), attribution.largestShiftTarget, attribution.loadState);
}, {reportAllChanges: true});
</script>Give every image and video explicit dimensions
Without dimensions, the browser can't reserve space for an image until it downloads, so the content below jumps down. Add width and height attributes that match the file's intrinsic aspect ratio. Keep height: auto in CSS so the image still scales responsively.
For elements whose size the browser can't infer, such as background-image containers and video posters, use the CSS aspect-ratio property.
<img src="/img/hero.webp" width="1600" height="900" alt="Example Co product range" fetchpriority="high">
<style>
img, video { max-width: 100%; height: auto; }
.hero-bg { aspect-ratio: 16 / 9; background: url(/img/hero.webp) center/cover; }
</style>Reserve fixed slots for ads, iframes and embeds
Ads, YouTube and map iframes, social embeds and review widgets often load at 0px height and then expand. Wrap each one in a container with a min-height equal to its most common rendered size. For ad slots with several possible sizes, reserve the most likely size, or the largest one if collapsing whitespace is acceptable.
Don't collapse an empty ad slot after it has rendered. Leave the reserved space or show a placeholder instead.
<div class="ad-slot" style="min-height:250px"> <!-- ad tag for 300x250 --> </div> <div style="aspect-ratio:16/9"> <iframe src="https://www.youtube-nocookie.com/embed/VIDEO_ID" width="560" height="315" style="width:100%;height:100%" title="Example Co demo" loading="lazy"></iframe> </div>
Stop injecting content above existing content
Cookie banners, promo bars, "app available" strips and late-loading navigation that push the page down are the most common causes of high field CLS. You have two options:
- Render them as overlays with
position: fixed, so they don't affect layout. - Include their space in the initial server HTML.
For content loaded by JavaScript, such as related products or infinite-scroll sections, insert it below the viewport or behind a user click. Shifts within 500 ms of a click or keypress don't count toward CLS.
.cookie-banner {
position: fixed;
bottom: 0; left: 0; right: 0;
z-index: 1000;
}
.promo-bar { min-height: 40px; } /* reserve space if it must be in flow */Prevent font-swap reflow
When a web font replaces the fallback font, text often re-wraps and shifts. You can reduce this in three ways:
- Preload the main font file.
- Use
font-display: optionalfor body text, or keepswapand add a metric-matched fallback usingsize-adjust,ascent-overrideanddescent-override. - Self-host the font instead of loading it from a third-party CDN, so it arrives sooner.
Tools such as the Fontaine library or the "Font style matcher" can calculate the override values.
<link rel="preload" href="/fonts/inter-var.woff2" as="font" type="font/woff2" crossorigin>
<style>
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 107%;
ascent-override: 90%;
descent-override: 22%;
line-gap-override: 0%;
}
body { font-family: "Inter", "Inter Fallback", sans-serif; }
</style>Animate with transform and keep pages bfcache-eligible
Animating top, left, margin, height or width moves surrounding content and counts as layout shift. Use transform and opacity instead, because they don't change layout. Also check that pages can use the back/forward cache, since bfcache restores are instant and shift-free.
To check, open DevTools > Application > Back/forward cache and click Test back/forward cache. Common blockers are unload event listeners and Cache-Control: no-store on HTML.
/* Shifts layout */
.menu { transition: top .3s; }
/* No layout shift */
.menu { transition: transform .3s; }
.menu.open { transform: translateY(0); }Re-test and monitor field data
Deploy your changes, clear any page or CDN cache, and re-run PageSpeed Insights. Lab CLS updates immediately. Field data is a rolling 28-day window, so it improves gradually over about four weeks.
In Google Search Console, open Experience > Core Web Vitals, check the CLS issue, and click Validate Fix to start a 28-day monitoring period.
Platform-specific notes
WordPress
WordPress core adds width and height attributes to images inserted through the block editor. Images hard-coded in themes or page builders often lack them. Plugins such as WP Rocket (Media > Add missing image dimensions) or Perfmatters can add them automatically. For ad plugins such as Advanced Ads, set a minimum height on each placement. Cookie plugins such as Complianz or CookieYes should be set to a floating or bottom-bar layout, not a push-down banner.
Shopify
Use Liquid's image_tag filter, for example {{ product.featured_image | image_url: width: 1200 | image_tag }}. It outputs width and height automatically. Announcement bars and app embeds from Online Store > Themes > Customize > App embeds are frequent culprits. Disable each embed in turn to find the one shifting content, and ask the app vendor about an overlay mode.
Next.js
next/image requires width and height, or the fill prop inside a sized parent, which prevents image shifts. next/font self-hosts fonts and generates size-adjust fallbacks automatically. Watch for client components that render content only after hydration, such as content gated by useEffect. Render placeholders of the same size on the server.
Wix / Squarespace / Webflow
You can't edit the image markup directly, so focus on what you control. Avoid strips or sections that appear after load through animations or interactions. Set fixed heights on embed and HTML blocks. In Webflow, give Embed elements a min-height in the Style panel and avoid 'appear' interactions that animate height or margin.
Cloudflare
Rocket Loader defers all scripts, which can make widgets render late and cause shifts. If your CLS rose after enabling it, turn it off under Speed > Optimization > Content Optimization. Third-party tags moved to Zaraz still need reserved space for any visible UI they inject.
Check that it worked
✅ How to verify
- Re-run pagespeed.web.dev for the URL. Lab CLS should be under 0.1, and 'Avoid large layout shifts' should list no significant elements.
- Record a reload and a full scroll in the Chrome DevTools Performance panel and confirm the Layout shifts track is empty or near-empty.
- Check the web-vitals console output, or your RUM tool, across several real page views on mobile.
- After 28 days, confirm that Search Console > Core Web Vitals shows the URL group as Good for CLS and that PageSpeed Insights field data reports under 0.1.
⚠️ Common mistakes
- Fixing only what the lab test shows. Field CLS often comes from scroll-triggered lazy content, late ads or cookie banners that a single lab load never triggers.
- Setting width and height in HTML but overriding them with CSS like height: 300px on responsive images, which distorts the aspect ratio or still causes reflow.
- Collapsing empty ad slots or hiding placeholders once content fails to load, which shifts everything below.
- Using loading="lazy" on the hero image or using a JavaScript lazy-loader that swaps in a 1x1 placeholder without dimensions.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
What is a good CLS score?
Google rates CLS as good below 0.1, needs improvement from 0.1 to 0.25, and poor above 0.25, measured at the 75th percentile of page loads. Our audit uses the same thresholds.
Why is my CLS different in PageSpeed Insights lab data and field data?
Lab data is one simulated page load with no scrolling or clicking. Field data comes from real Chrome users over 28 days. It includes shifts from scrolling, slow networks, ads and banners that appear later, so it is usually higher.
Do layout shifts after a user clicks count toward CLS?
No. Shifts within 500 ms of a click, tap or keypress are excluded, because the user expects the page to change. Shifts after scrolling or with no input do count.
How long does it take for a CLS fix to show in Search Console?
Search Console and PageSpeed Insights field data use a rolling 28-day window. Improvements appear gradually, and validating a fix in Search Console takes up to 28 days to complete.
How to Fix Slow Time to First Byte (TTFB) on Your Website
How to Fix Interaction to Next Paint (INP) Above 200ms
How to Fix Total Page Weight: Get Your Homepage Under 2 MB
How to Fix a Slow Largest Contentful Paint (LCP) on Mobile
How to Fix Render-Blocking Resources on Your Website
How to Fix a Missing or Unhelpful Custom 404 Page