Cumulative Layout Shift (CLS): What It Is and How to Fix It

In the fast-paced world of web browsing, few things frustrate users more than trying to click a button only to have it suddenly move, causing an accidental click on an ad or a broken link. This jarring experience is often caused by Cumulative Layout Shift (CLS), a critical metric that quantifies visual stability on web pages. In this article, we’ll explore what CLS is, why it matters, and how to fix common issues with real-world examples.


What Is Cumulative Layout Shift (CLS)?

CLS is part of Google’s Core Web Vitals, a set of metrics that measure user experience on websites. It calculates how often users experience unexpected layout shifts during a page’s lifespan. These shifts occur when elements on a page (like images, ads, or buttons) move without warning, often due to content loading asynchronously or dynamically.

How CLS Is Calculated

CLS is scored between 0 (perfect stability) and higher values (poor stability). The score is calculated using two factors for each layout shift:

  1. Impact Fraction: The portion of the viewport affected by the shift.
  2. Distance Fraction: How far unstable elements move (relative to the viewport height).

The score for each shift is the product of these two factors. The total CLS is the sum of all individual shift scores in the worst-performing 5-second window of page interaction. For example:

  • An image shifting down might impact 50% of the viewport (impact = 0.5) and move 20% of the viewport height (distance = 0.2).
  • This shift’s score is 0.5 × 0.2 = 0.1.

If another shift occurs within 1 second (e.g., an ad loading), its score is added to the window. The final CLS is the highest cumulative score across all such windows.


Why CLS Matters

  1. User Experience: Unexpected shifts frustrate users, leading to higher bounce rates.
  2. SEO: Google uses CLS as a ranking factor. A poor score can hurt search visibility.
  3. Conversion Rates: Buttons that move during checkout can directly impact sales.

Common Causes of CLS (With Examples and Fixes)

1. Images or Videos Without Dimensions

Problem: When images lack width and height attributes, the browser can’t reserve space upfront. Once loaded, the image pushes content downward.

<!– Bad: No dimensions –>
<img src=”image.jpg” alt=”Example”>

<!– Good: Dimensions included –>
<img src=”image.jpg” alt=”Example” width=”600″ height=”400″>

Fix:

  • Add width and height attributes.
  • Use CSS aspect-ratio to maintain proportions responsively:

img {
width: 100%;
height: auto;
aspect-ratio: 600/400;
}

2. Dynamically Injected Content

Problem: Ads, banners, or pop-ups that load after the page renders can displace existing content.
Example: A newsletter signup form injected above an article shifts the entire page downward.
Fix:

  • Reserve space in the layout beforehand. For example, use a placeholder container:

<div class=”ad-container” style=”min-height: 250px;”></div>

  • Load non-critical content after the page is interactive (e.g., using setTimeout or lazy loading).

3. Web Fonts Causing FOUT/FOIT

Problem: When web fonts load after fallback fonts (FOUT: Flash of Unstyled Text), text size changes can shift layouts.
Fix:

  • Use font-display: swap in @font-face to display fallback fonts immediately.
  • Preload critical fonts:

<link rel=”preload” href=”font.woff2″ as=”font” type=”font/woff2″ crossorigin>

  • Use tools like Font Style Matcher to align fallback and web font metrics.

4. Animations or Ads Triggering Layout Changes

Problem: Animations using properties like top or left can trigger layout recalculations.
Example: A floating chat widget expands upward, pushing content down.
Fix:

  • Use CSS transform (e.g., translate) for animations, which doesn’t affect layout:

.widget {
transform: translateY(100px); /* Instead of top: 100px */
}

  • For ads, ensure iframes have fixed dimensions.

How to Measure CLS

  • Google PageSpeed Insights: Provides CLS scores and diagnostics.
  • Chrome DevTools: Use the Performance tab to record shifts.
  • Lighthouse: Audits pages and identifies CLS culprits.

Aim for a CLS score below 0.1 for optimal user experience.


Conclusion

Cumulative Layout Shift is more than a technical metric—it’s a measure of how respectful your website is to users’ time and interactions. By reserving space for assets, optimizing fonts, and avoiding disruptive dynamic content, developers can drastically improve visual stability. Prioritizing CLS not only boosts SEO but also builds trust with visitors, ensuring they stay engaged and frustration-free.

FAQs

Understanding CLS and Its Impact on AdSense Ads

  1. What is Cumulative Layout Shift (CLS)?
    CLS is a Core Web Vital metric that measures how much visible content unexpectedly moves on a page while it’s loading. A high CLS score indicates poor user experience.

  2. How does CLS affect website performance?
    High CLS makes a site feel unstable, frustrating users and leading to higher bounce rates. It can also impact search rankings since Google considers CLS a ranking factor.

  3. What is a good CLS score?
    Google recommends a CLS score of 0.1 or lower for a good user experience. Anything above 0.25 is considered poor.

  4. Why does CLS happen on a website?
    CLS usually occurs due to ads, images, fonts, iframes, or dynamically injected content that loads after the initial page load.

  5. How do AdSense ads contribute to CLS?
    AdSense ads can cause layout shifts when they load dynamically, pushing content around if space isn’t reserved for them in advance.

Fixing CLS Issues Caused by AdSense Ads

  1. How can I prevent AdSense ads from causing CLS?
    You can prevent CLS by reserving space for ads using CSS and ensuring ad slots are properly sized.

  2. What CSS trick can I use to prevent layout shifts from ads?
    Use CSS to define a fixed height for ad slots:

.ad-slot {
min-height: 250px;
}

  1. This ensures the ad container remains stable while loading.

  2. Does using responsive ad units increase CLS?
    It can, but you can minimize the effect by defining minimum height constraints for ad slots.

  3. Can Auto Ads cause CLS issues?
    Yes, Auto Ads place ads dynamically, which can result in sudden layout shifts. To fix this, manually set ad placements in predictable areas.

  4. How can I diagnose CLS issues on my site?
    Use Google PageSpeed Insights, Lighthouse, or Chrome DevTools to analyze CLS and find problem elements.

Optimizing AdSense Ads for Better CLS Scores

  1. Does lazy-loading AdSense ads help with CLS?
    Yes, but you need to reserve space for the ads beforehand to prevent shifting when they load.

  2. Should I disable Auto Ads to fix CLS?
    Not necessarily. Instead, adjust Auto Ads settings to control placement and avoid unexpected layout shifts.

  3. Can using fixed-size ad slots improve CLS?
    Yes! Defining fixed dimensions ensures the ad space doesn’t change after the ad loads.

  4. How do I measure CLS in real time?
    Use the Chrome DevTools Performance tab to simulate CLS issues as pages load.

  5. Does CLS impact AdSense earnings?
    Yes, a poor CLS score can lead to lower rankings, fewer page views, and lower ad revenue.

Ad Formats and CLS Considerations

  1. Which AdSense ad formats are most likely to cause CLS?

    • Auto Ads (due to unpredictable placement)
    • Responsive display ads (if no size constraints are set)
    • Sticky ads (if they shift content unexpectedly)
  2. Are fixed-size display ads better for CLS?
    Yes, because they ensure the layout remains stable, avoiding sudden shifts.

  3. Do native ads affect CLS?
    Native ads blend with content and don’t usually cause CLS unless dynamically injected.

  4. What about CLS and video ads?
    Video ads can contribute to CLS if they appear unexpectedly or resize dynamically. Reserving space can prevent this.

  5. Should I disable in-article and in-feed ads to fix CLS?
    Not necessarily. Just ensure the ad container has a predefined height to avoid shifting.

Technical Fixes for CLS & AdSense

  1. How do I reserve space for ads without affecting design?
    Use a placeholder div with minimum height:

<div class=”ad-slot” style=”min-height: 250px;”>
<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
</div>

  1. Can CLS be completely eliminated?
    Not always, but you can minimize it with proper implementation of ad slots and loading behavior.

  2. How do I check CLS on mobile vs. desktop?
    Use Google Lighthouse or Web Vitals extension in Chrome and test different screen sizes.

  3. Do CLS issues differ between WordPress and custom-coded sites?
    Yes. WordPress users may face CLS due to theme-based ad placements, while custom sites can define fixed ad slots more easily.

  4. How does CLS relate to Core Web Vitals?
    CLS is one of the three Core Web Vitals, along with Largest Contentful Paint (LCP) and First Input Delay (FID), all impacting search rankings.

Long-Term Solutions & Best Practices

  1. Can reducing CLS improve SEO rankings?
    Yes, Google considers CLS in search rankings, so improving it helps SEO.

  2. How often should I check my CLS score?
    Regularly, at least once a month, to ensure new changes don’t negatively impact CLS.

  3. Does CLS affect ad viewability?
    Yes, if ads shift unexpectedly, users may scroll past them before they load, reducing ad impressions.

  4. Is there a WordPress plugin to fix CLS issues?
    Yes, plugins like WP Rocket, FlyingPress, and Perfmatters help optimize CLS for WordPress sites.

  5. Where can I learn more about fixing CLS for AdSense ads?

    • Google’s Web.dev CLS Guide
    • PageSpeed Insights reports
    • Google Search Central documentation
Scroll to Top