Course contentsShow
← Web Development
Lesson 1895 of 2,98235. Web Performance FundamentalsFree lesson

Cumulative Layout Shift (CLS) Explained

Understanding unexpected layout shifts and how they create poor user experiences.

Cumulative Layout Shift (CLS) Explained

You'll learn: How unexpected layout shifts frustrate users and why measuring them matters for web performance.

What is Cumulative Layout Shift?

Cumulative Layout Shift (CLS) measures the visual stability of your webpage. It quantifies how much visible content unexpectedly moves around during the page's lifetime. Think of reading a news article when suddenly an ad loads above your paragraph, pushing everything down—forcing you to find your place again or accidentally clicking the wrong button.

Why Layout Shifts Happen

Common culprits include:

  • Images without dimensions: Browser doesn't reserve space until the image loads
  • Dynamically injected content: Ads, embeds, or banners that push existing content
  • Web fonts loading: Text reflows when custom fonts replace fallback fonts
  • Animations: Elements moving without proper transforms

The User Experience Impact

CLS creates a jarring, frustrating experience. Imagine clicking a "Cancel" button just as it shifts down, causing you to hit "Confirm Purchase" instead. This isn't just annoying—it erodes trust and can lead to costly mistakes.

How CLS is Measured

CLS is calculated by multiplying two factors for each unexpected shift:

  • How much of the viewport was affected (impact fraction)
  • How far elements moved (distance fraction)

These individual shift scores are summed throughout the page's lifetime to produce the CLS score. Lower is better—a score under 0.1 is considered good.

Unlike LCP and FID/INP which measure single moments, CLS accumulates throughout the entire user session, making it unique among Core Web Vitals.

Key Takeaway: CLS measures the sum of all unexpected layout shifts on your page, directly reflecting visual stability—good experiences feel steady and predictable, not jumpy and chaotic.