Free SEO audit for new clients — claim yours
Home/Blog/Technical SEO/Cumulative Layout Shift (CLS): How to Fix It
Technical SEO

Cumulative Layout Shift (CLS): How to Fix It

Cumulative Layout Shift (CLS): How to Fix It
Table of contents
  1. Key Takeaways
  2. How CLS is calculated
  3. Common causes and fixes
    1. Images and media
    2. Ads and dynamic slots
  4. How to find and fix layout shifts: step by step
  5. CLS checklist by page element
  6. Common mistakes
  7. Related Guides
  8. Frequently Asked Questions
    1. What is a good CLS score?
    2. Does CLS only measure page load?
    3. Do shifts caused by clicking count towards CLS?
    4. Why is my lab CLS fine but field CLS poor?
    5. Do web fonts cause layout shift?
  9. Conclusion
  10. References

You start reading an article, and the paragraph suddenly jumps down the screen because an advert loaded above it. Or you go to tap “Cancel” and hit “Confirm” instead because a banner pushed the button. These unexpected movements are layout shifts, and Cumulative Layout Shift (CLS) is the Core Web Vital that measures them.

CLS is often the easiest of the three Core Web Vitals to fix once you know the cause, because most shifts come from a short list of culprits: images without dimensions, ads and embeds, injected banners, web fonts and certain animations. The tricky part is that shifts can happen at any time during a visit, not just during load, so lab tests can miss them.

Our Core Web Vitals overview introduces CLS. This guide goes deeper into how the score is calculated, how to find the elements that shift, and the specific CSS and HTML fixes for each cause.

Key Takeaways

  • A good CLS score is 0.1 or less at the 75th percentile of visits; above 0.25 is poor.
  • CLS reports the largest burst of unexpected shifts (a “session window”) during the whole page visit, not just loading.
  • Shifts within 500 ms of a click, tap or key press are treated as expected and excluded.
  • Always set width and height (or aspect-ratio) on images, videos, iframes and ad slots.
  • Reserve space for anything that loads late, and animate with transform rather than layout properties.

How CLS is calculated

Each time a visible element changes its start position between two frames without user input, the browser records a layout shift and gives it a score:

layout shift score = impact fraction × distance fraction

  • Impact fraction is the share of the viewport affected by the unstable elements across both frames.
  • Distance fraction is the greatest distance any unstable element moved, relative to the viewport’s largest dimension.

For example, if an element covering half the viewport moves down by a quarter of the viewport height, the affected area spans about 75% of the viewport and the distance fraction is 0.25, giving a score of roughly 0.75 × 0.25 = 0.1875 for that single shift. That alone would fail the “good” threshold.

Shifts are grouped into session windows: bursts of shifts with less than one second between them, lasting at most five seconds in total. CLS is the score of the worst session window. This means a long-lived page is not penalised for small shifts spread over a long visit, but one bad burst counts fully.

CLS valueRating
≤ 0.1Good
0.1 – 0.25Needs improvement
> 0.25Poor

Shifts that happen within 500 ms of a discrete user input, such as expanding an accordion after a tap, are flagged as expected and excluded. Scrolling, dragging and pinch-zooming do not count as input for this purpose. Elements that move using CSS transform do not create layout shifts either.

Common causes and fixes

CauseWhat happensFix
Images and videos without dimensionsSpace appears only when the file loads, pushing content downAdd width and height attributes or CSS aspect-ratio
Ads, embeds and iframesSlots expand when the ad or widget loadsReserve space with min-height or aspect-ratio; do not collapse empty slots
Injected contentCookie notices, promo bars or “related posts” inserted above existing contentReserve space, overlay the element, or insert below the viewport
Web fontsText reflows when the custom font replaces the fallbackPreload key fonts, use font-display: optional or tune fallback metrics with size-adjust
Non-composited animationsAnimating top, left, height or margin moves other elementsAnimate transform and opacity instead
Late-loading CSS or JavaScript layoutsComponents restyle or re-render after first paintServer-render layout; include critical styles up front

“Always include width and height size attributes on your images and video elements.”

— web.dev, Optimize Cumulative Layout Shift

Images and media

Modern browsers use the width and height attributes to calculate an aspect ratio before the image loads, even when CSS makes the image responsive. This is the single most common CLS fix:

<img src="team.webp" width="1200" height="800" alt="Our team"
     style="width: 100%; height: auto;">

/* For embeds or containers without intrinsic size */
.video-embed {
  aspect-ratio: 16 / 9;
  width: 100%;
}

Ads and dynamic slots

Reserve the most likely ad size for each slot. If the slot can show several sizes, reserve the smallest common height to limit the shift.

.ad-slot-leaderboard {
  min-height: 90px;   /* match the smallest size you serve */
}

“Removing the space set aside for elements can cause just as much CLS as inserting content.”

— web.dev, Optimize Cumulative Layout Shift

So keep the reserved space even when no ad fills the slot, and show a placeholder rather than collapsing it.

How to find and fix layout shifts: step by step

  1. Check field data in Search Console’s Core Web Vitals report and PageSpeed Insights. Note whether CLS fails on mobile, desktop or both, and on which templates.
  2. Find the shifting elements. The “Layout shift culprits” insight in a Lighthouse audit and the Chrome DevTools Performance panel highlight which elements moved and why.
  3. Reproduce real behaviour. Scroll the page, accept the cookie banner, wait for ads and lazy-loaded content. Many shifts happen after load, which a basic lab test misses.
  4. Collect field attribution with the web-vitals library’s attribution build to log the largest shifting element for real visitors.
  5. Apply the matching fix from the table above, starting with the largest shifts on your highest-traffic templates.
  6. Check back-forward cache eligibility. Pages restored from the bfcache appear instantly with no new shifts; Chrome DevTools’ Application panel shows whether a page is eligible.
  7. Monitor field data for four weeks to confirm the improvement.

CLS checklist by page element

  • Hero and inline images have dimensions; lazy-loaded images below the fold too (see lazy loading and SEO).
  • YouTube, map and social embeds sit in fixed-ratio containers.
  • Cookie consent and promo banners overlay the page or have reserved space.
  • Fonts are preloaded or use metric-matched fallbacks.
  • Sticky headers do not change height after load.
  • Infinite scroll or “load more” inserts content below the viewport or after a user action.
  • Carousels animate with transform.

Common mistakes

  • Testing only the first few seconds. CLS covers the whole visit; late ads and banners count.
  • Removing dimensions for “responsive” images. Keep the attributes and set height: auto in CSS instead.
  • Collapsing empty ad slots, which creates a shift of its own.
  • Inserting a banner at the top of the page after load, the classic cause of high CLS on news and ecommerce sites.
  • Animating layout properties such as height for accordions on load.
  • Ignoring desktop. Wider layouts with sidebars and ads can have different shifts from mobile.

CLS fixes often overlap with other speed work: dimensioned images help LCP work too, and font strategy matters for both. For the third Core Web Vital, see our guide to Interaction to Next Paint, and for mobile layouts in general, our mobile SEO guide.

Frequently Asked Questions

What is a good CLS score?

0.1 or less at the 75th percentile of page visits. Between 0.1 and 0.25 needs improvement, and above 0.25 is poor.

Does CLS only measure page load?

No. CLS covers the whole time a page is open and reports the worst burst of unexpected shifts, so shifts from late ads or banners count.

Do shifts caused by clicking count towards CLS?

Shifts within 500 milliseconds of a click, tap or key press are treated as expected and excluded. Scrolling does not count as input for this rule.

Why is my lab CLS fine but field CLS poor?

Lab tests usually only cover initial load without interaction. Real users scroll, see ads and banners, and trigger lazy-loaded content, which can cause shifts the lab never sees.

Do web fonts cause layout shift?

They can, when the custom font has different dimensions from the fallback. Preloading fonts, using font-display: optional or matching fallback font metrics reduces this.

Conclusion

CLS is about keeping promises: once something appears on screen, it should stay where it is. Give every image, embed and ad slot a reserved size, keep injected content out of the reading flow, tame web fonts and animate with transforms. If you would like your layout shifts diagnosed and fixed across every template, our page speed optimization service can help, or get a free quote.

References

  1. Cumulative Layout Shift (CLS) – web.dev
  2. Optimize Cumulative Layout Shift – web.dev
  3. Web Vitals – web.dev
  4. Understanding Core Web Vitals and Google search results – Google Search Central
  5. Core Web Vitals: What They Are and How to Improve Them – Semrush Blog
Rohit Choudhary
Written byRohit ChoudharyCo-Founder, My SEO Experts

Rohit Choudhary is the co-founder of My SEO Experts and has more than 14 years of hands-on experience in SEO, paid advertising and digital marketing. Since starting out in 2011 he has helped hundreds of businesses grow through practical, data-driven search strategies, and he also serves as a consulting Digital Marketing Director for several US-based companies.

Keep reading

Related articles

Ready to grow your business online?

Get a free, no-obligation proposal tailored to your goals and budget.

CallFree Quote