How to fix CLS: find what moves, then keep it still
Layout shift is the page jumping while people read or tap. Here’s how CLS is scored, why Lighthouse can miss it, how to find the element that moves on real visits, and the fix for each cause.
Nour9 min read · 
Stop the page jumping.
You start reading an article and the text drops half a screen. You go to tap a button and an ad slides in, so you tap the ad instead. That jump has a name, layout shift, and Google scores it with a metric called Cumulative Layout Shift, or CLS.
The good news is that CLS is usually the easiest of the three Core Web Vitals to fix. The causes are a short list, and each one has a clear fix. The hard part is finding which element is moving for your real visitors, because it’s often not the one you see when you test the page yourself. Here’s how to do both.
The short answer
A good CLS is 0.1 or less for three out of four real visits, the 75th percentile. Over 0.25 is poor. To fix it, find the element that moves on real visits, work out what pushed it, and reserve space for that thing before it arrives. Almost every layout shift comes from something that loads late without a place kept for it: an image, an ad, a banner or a font.
A layout shift is the page making room for something it didn’t plan for. Plan for it, and the shift is gone.
What CLS measures
Every time something visible moves on its own, the browser gives that move a score. The score grows with two things: how much of the screen moved, and how far it moved. A small badge nudging a few pixels barely counts. The whole article sliding down by a third of the screen counts a lot.
Shifts that happen close together are grouped into bursts, and your CLS is the score of the worst burst during the whole visit, not just the first few seconds. A few details matter when you’re hunting for the cause:
- Moves you asked for don’t count. If something moves within half a second of a click, tap or key press, like a menu opening, it’s not a layout shift.
- Scrolling isn’t a shift. Content moving because you scrolled doesn’t count. Content that jumps while you scroll, like a lazy-loaded image without a size, does.
- Moving with transform doesn’t count. An animation that slides something with CSS transform doesn’t push anything else, so it’s free. Changing top, margin or height does push things, and it counts.
- Only Chromium browsers report it. Chrome, Edge, Samsung Internet and other Chromium browsers measure CLS. Safari and Firefox don’t, so your CLS numbers come from those visitors only.
Why Lighthouse can miss it
A common surprise: Lighthouse says CLS is 0, and Search Console says it’s failing. Both are right. Lighthouse loads the page once, on one screen size, and stops once the page has loaded. It never scrolls, never waits for the cookie banner to time out, and never sees the ad that loads ten seconds later.
Real visitors do all of that. They scroll into lazy-loaded images, they sit on the page while a newsletter popup pushes the footer, and they arrive with a cold cache, so fonts and images come in late and in a different order. Google judges your site on those real visits over the last 28 days, which is why the two disagree. We explain the gap in more detail in Your Lighthouse score is green. Why are your Core Web Vitals failing?
Find what moves
- 01Check which pages and devices fail. Search Console groups failing pages by type, and PageSpeed Insights shows the field CLS for a page on Mobile and Desktop separately. Phones fail more often, because content wraps onto more lines and moves further.
- 02Watch it happen in Chrome. Open DevTools, press Cmd or Ctrl + Shift + P, run “Show Rendering” and tick Layout Shift Regions. Every shift flashes blue. Reload, scroll to the bottom slowly, and wait a while. Slow the network down in the Network tab, since many shifts only show up on slow loads.
- 03Read the culprit in the Performance panel. Record a page load. The Layout shifts track lists each shift, its score and the elements that moved. PageSpeed Insights shows the same list under “Avoid large layout shifts”.
- 04Confirm it on real visits. What moves for you on a fast laptop isn’t always what moves for your visitors. Collect the element behind the biggest shift on each real visit, and fix the one that shows up most.
One thing to keep in mind when reading the results: the element that moved is the victim, not always the cause. If an article heading moves, look at what’s above it. Something there grew, appeared or swapped, and that’s what you need to fix.
Images and videos without a size
The classic cause. The browser lays out the page before the image arrives, gives it no height, then pushes everything down when it loads. The fix is to tell the browser the size up front.
- Add width and height to every img and video. The browser uses them to work out the shape and keeps the right amount of space, even when CSS makes the image responsive with width: 100% and height: auto.
- Use aspect-ratio for everything else. Background images, iframes and placeholder boxes can use the CSS aspect-ratio property, for example aspect-ratio: 16 / 9.
- Check images added by your CMS or editor. Images in blog posts and product descriptions often lose their width and height on the way in. Make sure your templates output them.
- Lazy-loaded images need a size too. They load while people scroll, which is exactly when a shift is most annoying.
Ads, embeds and iframes
Ads, YouTube embeds, maps, social posts and review widgets usually arrive last and decide their own size. That makes them the biggest source of shifts on many sites.
- Reserve the space. Give every ad slot and embed a min-height that matches the size it usually fills. If the ad comes back smaller, a little empty space is much better than a jump.
- Don’t collapse empty slots. If no ad fills the slot, leave the space or show a placeholder. Removing it moves everything below it.
- Keep late ads away from the top. A slot near the top of the page pushes the most content. Ads further down, or in a sidebar, move less.
- Use a placeholder for heavy embeds. A fixed-size preview image that loads the real video or map on click is faster and never shifts.
Most of these come from third parties, and they cost more than layout shift. We cover the whole bill in How much do third-party scripts slow down your site?
Banners and content added late
Cookie notices, promo bars, “download our app” banners and newsletter signups are often added by JavaScript at the top of the page after it has loaded. Everything below them moves down.
- Overlay instead of insert. A banner fixed to the bottom or top of the window covers content without pushing it, and doesn’t count as a shift.
- Or keep its space from the start. If the banner has to sit in the page, render an empty box of the same height in the HTML and fill it later.
- Show content loaded from an API in a box of the right size. Recommendations, reviews and “related posts” can use a skeleton of the same height while they load.
- Never add content above what people are reading. If something new has to appear, add it below the first screen, or wait until the visitor asks for it.
Web fonts
When a web font arrives, the browser swaps it in for the fallback font. If the two are different sizes, lines rewrap, headings grow or shrink, and everything below moves. It’s a small shift on its own, but it hits every new visitor on every page.
- Match the fallback to the web font. The size-adjust, ascent-override and descent-override settings in @font-face make the fallback take the same space as the real font. Tools like next/font in Next.js and Fontaine set them up for you.
- Preload the main font. The sooner it arrives, the more often it’s there before the first paint, and there’s nothing to swap.
- Consider font-display: optional. The browser uses the web font only if it’s ready almost straight away, and otherwise keeps the fallback for that visit. No swap, no shift.
Animations
Animations that change the size or position of an element in the layout push its neighbours around, and each frame can add to CLS. A sliding banner, an expanding accordion that opens by itself, or a carousel that changes height between slides are common culprits.
- Animate transform and opacity only. Use transform: translate() to move and transform: scale() to grow. They don’t affect the layout, so they never count.
- Give carousels a fixed height. Every slide should take the same space, or the content below jumps each time it turns.
Check the fix on real visits
Layout shift is the metric where lab tests and real visits disagree the most, so a clean Lighthouse run doesn’t prove much. And waiting for Google takes about four weeks, as we explain in Core Web Vitals assessment failed? What it means and how to fix it.
CLS also comes back easily. A new ad partner, a redesigned banner or a font change can undo a fix without anyone noticing, so it’s worth checking after every release, not once.
That’s what CodeGecko does. It collects CLS from real visits and names the element that moved the most on each one, so you see which element is behind most of your shifts, page by page and per device. It shows CLS by browser and network speed in a Who saw it table, which helps when the shift only happens on slow connections. Then it compares each release with the one before it, so you know the day you ship whether a change made the page jump, or stopped it. The docs list everything we measure, and the demo shows a release where a new carousel added layout shift.
- Find the pages and devices where CLS fails, phones first.
- Find the element that moves on real visits, then look above it for the cause.
- Reserve space for images, ads, embeds and banners before they load.
- Match your fallback font and animate with transform only.
- Ship it, and compare the release with the one before it on real visits.
Common questions
What is a good CLS score? 0.1 or less at the 75th percentile is good. Over 0.25 is poor. Anything in between needs improvement.
Why is my CLS 0 in Lighthouse but failing in Search Console? Lighthouse only watches the page load, on one device, without scrolling. Real visitors scroll, wait, and load things in a different order, and Google judges the real visits.
Does CLS have a unit? No. It’s a score that combines how much of the screen moved and how far, so 0.1 isn’t seconds or pixels.
Why don’t I see CLS for Safari or Firefox visitors? Those browsers don’t report layout shifts yet, so every CLS number, including Google’s, comes from Chromium browsers like Chrome and Edge.
Do layout shifts from a click count? Not if the shift starts within half a second of a click, tap or key press. A menu opening when you tap it is fine. A banner that appears two seconds later still counts.
NourBuilding CodeGeckoSenior frontend engineer, night-shift gamer, weekend photographer, and the human who taught a gecko to watch your deploys.

Get in early.
We’re letting teams in a few at a time. Join the waitlist and we’ll email you once, when your spot opens.
Go deeper
Keep reading

Same engine, different numbers.

Make the server answer faster.

How much speed counts.