Cumulative Layout Shift (CLS): stop your page from jumping
How CLS is calculated, the usual causes of layout shift, from images without dimensions to late fonts and injected banners, and how to fix each one.
By Abdessamad Bettal. Published . 4-minute read.
On this page
Cumulative Layout Shift (CLS) measures how much visible content moves around unexpectedly while someone uses a page. It is the Core Web Vital behind a familiar annoyance: you go to tap a link and the page jumps, so you tap an advert instead. A score of 0.1 or less is good, more than 0.25 is poor, measured at the 75th percentile of real visits.
Unlike LCP and INP, CLS is not a time. It is a score, and it is usually the easiest of the three to fix once you know what is moving.
How the score is calculated
Each time a visible element moves from one frame to the next without the visitor causing it, the browser records a layout shift. Its score is the product of two fractions:
- Impact fraction: how much of the viewport the moving elements cover, before and after the move combined.
- Distance fraction: how far they moved, relative to the viewport's height or width.
Take a paragraph that covers half the screen and moves down by a quarter of the screen. Before and after the move together it covers three quarters of the screen, so the shift scores 0.75 × 0.25, about 0.19 for that one shift: already well over the limit.
Shifts that happen close together are grouped into session windows: a window continues as long as shifts arrive within one second of each other, up to five seconds in total. CLS is the score of the worst window during the visit, not the total for the whole visit, so long-lived pages are not penalised just for being open a long time.
Two kinds of movement do not count. Shifts within half a second of a tap, click or key press are expected, because the visitor caused them. And animations using CSS transform do not move the layout, so they never count.
Common causes and fixes
Images and videos without dimensions
When an <img> has no size, the browser reserves no space for it. When the file arrives, everything below jumps down. This is the most common cause of CLS.
Always give images a width and height. Browsers use the two numbers to work out the aspect ratio and reserve the right amount of space, even when CSS makes the image responsive:
<img src="/team.webp" width="1200" height="800" alt="Our team" />
img {
max-width: 100%;
height: auto;
}
For embeds and other content without intrinsic dimensions, reserve the space with CSS aspect-ratio. The page size checker counts the images on a page that are missing their dimensions.
Adverts, embeds and late widgets
Ads, video embeds, social posts and recommendation widgets often load after the rest of the page and push content down when they arrive. Reserve their space in advance with a min-height that matches the most likely size. If a slot sometimes stays empty, show a placeholder rather than collapsing it.
Content inserted above what the visitor is reading
Cookie notices, newsletter bars and "install our app" banners that are inserted at the top of the page push everything down. Either reserve their space from the start, or show them as an overlay that does not move the content, for example fixed to the bottom of the screen.
The same applies to content loaded on scroll. If an infinite list or a lazy-loaded section inserts content above the current position, the page jumps. Insert new content below what the visitor is looking at.
Web fonts that change size
When a web font finishes loading and replaces the fallback font, text can change width and height, reflowing everything around it. Three things help:
- Preload the one or two font files used in the first screen, so they arrive early.
- Match the fallback to the web font with the
size-adjust,ascent-overrideanddescent-overridedescriptors, so the swap barely changes the layout. Some frameworks generate these values automatically. - Use
font-display: optionalwhere a brief fallback is acceptable, which avoids a late swap entirely.
Animations that move the layout
Animating top, left, margin or height moves real layout and creates shifts. Animate transform and opacity instead: they look the same to the visitor, do not count toward CLS and are cheaper for the browser to draw.
Shifts after loading count too
CLS is measured for the whole visit, not just while the page loads. A menu that pushes content down when it opens on its own, an accordion that expands after a timer, or a price that loads late and changes a line's height can all add shifts long after the first screen is ready. Lab tools that only record the page load will miss these, which is one reason lab and field CLS often differ. Our guide to field data vs lab data explains the difference.
Find what is moving
In Chrome DevTools, the Performance panel highlights layout shifts in a recording and shows which elements moved. The Rendering tab can also flash shifted regions on screen as they happen, which is the fastest way to spot them while you scroll. Test on a phone-sized viewport, where the same shift covers a larger share of the screen and so scores higher.
Then check your field data. A site lookup on pagespeed.tools shows CLS for phones and desktops and how it changed over 40 weeks, so you can confirm the fix once the 28-day window has caught up.
For how CLS fits with the other two measures, see Core Web Vitals explained.
Check it on your own site
Written by
Web developer and the builder of pagespeed.tools: free tools for finding what slows a website down and fixing it.
More guides
Core Web Vitals explained: LCP, INP and CLS in plain languageWhat the three Core Web Vitals measure, the limits Google uses, how the 75th percentile and the 28-day window work, and where to start fixing a slow site.5-minute read
Largest Contentful Paint (LCP): what slows it down and how to fix itHow LCP is measured, the four parts every LCP time breaks into, and the specific fixes for slow servers, late-discovered images, heavy files and render-blocking code.5-minute read
Interaction to Next Paint (INP): make your page respond to every tapHow INP measures responsiveness, the three phases of every interaction, how to find the slow ones on your site, and practical ways to keep the main thread free.4-minute read