How to fix Cumulative Layout Shift (CLS)

Learn how to fix CLS by finding which elements move, then reserving space for images, ads, embeds, fonts and banners so your pages stay still while they load.

To fix Cumulative Layout Shift (CLS), find which elements move while the page loads, then reserve space for them before they arrive. In practice that means setting width and height on images and videos, giving ad slots and embeds a fixed size, loading fonts so the text doesn't jump, and never inserting banners above content that's already visible.

CLS measures how much visible content unexpectedly moves around. You've felt it: you go to tap a link and the page shifts, so you tap an ad instead. Google uses CLS as one of its Core Web Vitals. A good score is 0.1 or less, measured at the 75th percentile of real visits.

The good news is that CLS is usually the easiest Core Web Vital to fix once you know what's moving. Here's how I track it down and fix it.

What CLS measures

Each time a visible element moves without the user causing it, the browser calculates a layout shift score based on how much of the screen moved and how far. CLS groups shifts that happen close together into "session windows" and reports the largest window.

Two details that matter:

  • Shifts within half a second of a user interaction, like tapping a button that opens a menu, don't count. Expected movement is fine.
  • CLS is measured across the whole visit, not just the initial load. Content that jumps when someone scrolls down (late ads, lazy-loaded content without space reserved) counts too.

Google's explainer on web.dev covers the calculation in detail if you want the maths.

Find what's shifting

Don't guess. These tools show you exactly which elements move:

  1. PageSpeed Insights. Run your URL. The top section shows real-user CLS (if your site has enough traffic). The diagnostics section lists "Avoid large layout shifts" with the elements responsible.
  2. Chrome DevTools Performance panel. Record a page load. Layout shifts appear in the timeline, and clicking one highlights the element that moved.
  3. Search Console Core Web Vitals report. Groups URLs with the same problem, so you can see whether it's one template or the whole site.
  4. Browse on a real phone with a slower connection. Shifts that are invisible on fast office Wi-Fi often show up clearly on mobile data.

Lab tools only measure the initial load. If real-user CLS is bad but lab CLS is fine, the shift is probably happening later: on scroll, after a cookie banner, or when an ad loads.

Images and videos without dimensions

This is the most common cause I find. When an image has no width and height, the browser doesn't know how much space to reserve, so it gives it zero height. When the image arrives, everything below jumps down.

The fix is to set the dimensions so the browser can work out the aspect ratio:

<img src="/img/team.webp" width="1200" height="800" alt="Our team outside the workshop">

With modern CSS like img { max-width: 100%; height: auto; }, the image still resizes responsively. The browser uses the width and height attributes only to calculate the ratio and reserve the right space.

For responsive containers, the CSS aspect-ratio property does the same job:

.video-embed {
  aspect-ratio: 16 / 9;
  width: 100%;
}

WordPress adds width and height to images inserted through the editor automatically. Problems usually come from images in theme templates, sliders and page builder widgets. Shopify and Next.js (next/image) handle this well when used correctly.

Ads, embeds and iframes

Third-party content is the next big source. Ads, YouTube embeds, maps, social media posts and review widgets load late and often have unpredictable sizes.

  • Reserve space with a minimum height. Give each ad slot a fixed min-height that matches its most common size.
  • Don't collapse empty slots if no ad fills them, or collapse them only below the fold where the shift is out of view.
  • Use placeholders for embeds. A YouTube video can show a thumbnail with the correct ratio, loading the real player only on click. This also helps speed.
  • Set iframe dimensions with width and height attributes or an aspect-ratio container.

Review widgets and chat bubbles that inject a block into the page after load are frequent offenders. If you can't control the widget, put it in a container with a reserved height.

Web fonts that cause text to jump

When a custom font loads after the page has rendered with a fallback font, the text changes size and the layout shifts. Sometimes this is minor. With a very different fallback, whole paragraphs reflow.

Ways to reduce it:

  • Preload the main font file so it arrives sooner.
  • Self-host fonts rather than loading from a third-party server, which removes a connection step.
  • Use `font-display: optional` for fonts where it's acceptable to use the fallback on a slow first visit. Or keep swap but use a fallback font that's close in size.
  • Adjust the fallback using CSS size-adjust and related descriptors, so the fallback takes up nearly the same space as the web font. Next.js's next/font does this automatically.
  • Load fewer font files. Every weight and style is another file that can arrive late.

Banners, pop-ups and injected content

Content added above what the visitor is already looking at pushes everything down. Common culprits:

  • Cookie consent banners that push the page down instead of overlaying it.
  • "Free shipping" or announcement bars added by an app or script after load.
  • Promo strips inserted by A/B testing tools.
  • "Related products" or recommendation blocks that load late in the middle of content.

Fixes:

  1. Make cookie banners and announcement bars overlay the page (fixed position) rather than pushing content down, or render them in the initial HTML so they're there from the start.
  2. Reserve space for late-loading blocks with a skeleton placeholder of the right height.
  3. Put dynamic content below the visible area where possible.
  4. Avoid animations that change layout properties like top, height or margin. Use transform instead, which doesn't trigger layout shifts.

A CLS fix checklist

Here's the order I work through on a site with a CLS problem:

CheckFix
Images missing width/heightAdd dimensions or aspect-ratio
Sliders and carouselsSet a fixed height for the container
Ads and embedsReserve min-height, use placeholders
FontsPreload, self-host, adjust fallback, fewer files
Cookie and promo bannersOverlay or render in initial HTML
Late-loaded widgetsReserve space or move lower
AnimationsUse transform, not layout properties
Lazy-loaded contentPlaceholders with correct height

After fixing, real-user CLS in Search Console takes about 28 days to fully reflect changes, because it's based on a rolling window of data. Lab tools show the improvement immediately.

For the other two Core Web Vitals, see my guides on fixing Largest Contentful Paint and fixing INP.

The short version

CLS is about things moving that shouldn't. Find the shifting elements with PageSpeed Insights or DevTools, then reserve space for them: dimensions on images and videos, fixed slots for ads and embeds, careful font loading, and banners that overlay rather than push. Aim for 0.1 or less on real users.

If your site still jumps around and you can't find why, I can trace it for you as part of my speed optimisation service. Send me the URL and I'll take a look.

Available for new projects

Need a hand with this?

Tell me what you need: a new site, a fix, a SaaS or an app. You'll get a clear plan and price within a day.

Start a project WhatsApp me