# CLS

> The CLS (Cumulative Layout Shift) metric measures the visual stability of a page.

## How do I fix Cumulative Layout Shift (CLS)?

The metric that measures the largest burst of unexpected layout shifts during the page lifetime. A good value is 0.1 or less. Improved by setting sizes for images and reserving space for ads and dynamic content.

- Topic: Performance
- Type: concept

## Example

Wrong:

```html
<img
  src="/photo.jpg"
  alt="Product photo"
>
```

Right:

```html
<img
  src="/photo.jpg"
  width="800"
  height="600"
  alt="Product photo"
>
```

With `width` and `height`, the browser reserves space from the aspect ratio before the image loads, so content below does not jump.

## Common mistakes

- Inserting a banner above content after load, which pushes the whole page down.

## Key points

- Images, videos and iframes have `width` and `height` attributes or an `aspect-ratio`.
- Space for ads, embeds and banners is reserved before they load.
- Animations use `transform` instead of changing `top`, `left`, `width` or `height`.
- Web fonts use `font-display` and fallback metrics so text does not jump when they load.

## Interview questions

### What is a good CLS score?

0.1 or less at the 75th percentile of visits is good, and over 0.25 is poor.

### Do layout shifts after a click count toward CLS?

No. Shifts within 500 ms of a tap, click or key press are excluded, because the user expects them.

### How is CLS calculated?

Shifts are grouped into session windows of up to 5 seconds, and CLS is the score of the worst window, based on how much content moved and how far.

## Related cards

- [Core Web Vitals](https://wonderium.dev/web/core-web-vitals.md)
- [aspect-ratio](https://wonderium.dev/css/aspect-ratio.md)
- [LCP](https://wonderium.dev/web/lcp.md)
- [Reflow](https://wonderium.dev/web/reflow.md)
- [font-display](https://wonderium.dev/css/font-display.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/cls
- Last updated: 2026-11-25
