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
widthandheight(oraspect-ratio) on images, videos, iframes and ad slots. - Reserve space for anything that loads late, and animate with
transformrather 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 value | Rating |
|---|---|
| ≤ 0.1 | Good |
| 0.1 – 0.25 | Needs improvement |
| > 0.25 | Poor |
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
| Cause | What happens | Fix |
|---|---|---|
| Images and videos without dimensions | Space appears only when the file loads, pushing content down | Add width and height attributes or CSS aspect-ratio |
| Ads, embeds and iframes | Slots expand when the ad or widget loads | Reserve space with min-height or aspect-ratio; do not collapse empty slots |
| Injected content | Cookie notices, promo bars or “related posts” inserted above existing content | Reserve space, overlay the element, or insert below the viewport |
| Web fonts | Text reflows when the custom font replaces the fallback | Preload key fonts, use font-display: optional or tune fallback metrics with size-adjust |
| Non-composited animations | Animating top, left, height or margin moves other elements | Animate transform and opacity instead |
| Late-loading CSS or JavaScript layouts | Components restyle or re-render after first paint | Server-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
- 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.
- 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.
- 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.
- Collect field attribution with the
web-vitalslibrary’s attribution build to log the largest shifting element for real visitors. - Apply the matching fix from the table above, starting with the largest shifts on your highest-traffic templates.
- 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.
- 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: autoin 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
heightfor 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.
Related Guides
- How to Use PageSpeed Insights
- How to Run a Lighthouse Audit (and Act on the Results)
- Screaming Frog for Beginners: Crawl Your Site Like Google
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.




