In short
CLS (Cumulative Layout Shift) measures unexpected movements of visible elements over the whole lifetime of the page: text that drops down when an image arrives, a button that slips away under the finger. Google rates it good at 0.1 or less for at least 75% of visits. The fix is almost always the same: reserve space in advance for everything that is displayed late.
Why it matters
The browser renders the page as resources arrive. If it does not know the size of an image, an ad or a block injected by a script, it gives it zero height, then pushes everything below it down when the element arrives. The visitor loses their place in the text or clicks the wrong button.
Each shift gets a score that combines the share of the screen affected and the distance moved. CLS does not add up every shift in the visit: it keeps the largest burst, that is, the worst window of closely spaced shifts, lasting at most five seconds. Shifts that occur within 500 milliseconds of a visitor action (click, tap, key press) do not count: opening an accordion does not hurt CLS.
Two practical consequences: CLS has no unit, and it is also decided after loading, while scrolling.
What it improves
- Core Web Vitals CLS is one of the three, and the easiest to fix for good.
- Reading comfort No more jumping text during loading.
- Misclicks Fewer accidental taps on an ad or a neighboring button.
- Rankings A modest effect, as with the other Core Web Vitals.
- Generative engines No documented effect.
How to check
The verdict comes from the field: the top block of PageSpeed Insights, Search Console (Core Web Vitals report) or CrUX Vis, with a p75 of 0.1 or less. See analyze real-user CrUX data (opens in a new tab).
Lighthouse only measures shifts during loading, without scrolling or interaction. A lab CLS of zero with a poor field CLS points to late shifts: lazy-loaded images without dimensions, ads, content inserted while scrolling.
To list a page's shifts and the elements involved, paste this into the console, then scroll through the page:
new PerformanceObserver((liste) => {
for (const entree of liste.getEntries()) {
if (entree.hadRecentInput) {
continue;
}
console.log('Shift', entree.value.toFixed(4), entree.sources.map((source) => source.node));
}
}).observe({ type: 'layout-shift', buffered: true });
How to implement
Step 1 — Locate the shifts
- In Chrome DevTools, open the “Performance” panel, record a page load with network throttling, then click the shifts flagged in the timeline: the tool identifies the moved element and, when it can, the cause.
- In the “Rendering” tab (More tools menu), check “Layout Shift Regions”: shifted areas flash on screen as you browse.
- Test at mobile width, with and without accepting cookies, and scrolling all the way down.
- Test a first visit with the cache cleared: that is when fonts and images cause the most shifts.
Then assign each shift to one of the causes below.
Images, videos and iframes without dimensions
Always specify width and height in the HTML. The browser derives the aspect ratio from them and reserves the space before the download, even if CSS resizes the image.
<img src="/images/produit.webp" width="800" height="600" alt="Product description" loading="lazy">
<iframe src="https://www.youtube-nocookie.com/embed/IDENTIFIANT" width="560" height="315"
title="Video title" loading="lazy"></iframe>
In CSS, keep the aspect ratio:
img, video {
max-width: 100%;
height: auto;
}
.conteneur-video {
aspect-ratio: 16 / 9;
width: 100%;
}
If the aspect ratio changes with the screen (a different image on mobile), declare width and height on each source of the picture element. See set width/height (opens in a new tab).
Ads, embeds and injected blocks
An ad slot that starts empty and then fills up is the leading cause of CLS on media sites.
.emplacement-pub {
min-height: 250px;
}
- Reserve the height of the slot's most common format, and do not collapse the space when no ad is served.
- Do the same for embedded content (social networks, maps, reviews) whose final height is known or can be estimated.
- Never insert content above content that is already displayed, except in response to a visitor action.
Details in reserve space for media and ads (opens in a new tab).
Banners, announcement bars and notifications
A consent banner or promotional bar injected at the top of the page pushes all the content down.
- Display the banner as an overlay (
position: fixed), without moving the content. - If an announcement bar has to stay in the flow, generate it on the server with a fixed height so that it is present from the first render.
See test before and after cookie consent (opens in a new tab).
Web fonts
When the web font replaces the fallback font, line width and height change and the text shifts.
- Host fonts as WOFF2 on your own domain and preload the one used by the text visible first.
- Bring the fallback font's metrics closer to those of the web font:
@font-face {
font-family: "Inter Repli";
src: local("Arial");
size-adjust: 107%;
ascent-override: 90%;
descent-override: 22%;
line-gap-override: 0%;
}
body {
font-family: "Inter", "Inter Repli", sans-serif;
}
These values are an example for Inter and Arial: calculate them for your font with a dedicated tool. font-display: optional removes any shift, at the cost of not showing the web font on a slow first visit. See optimize fonts (opens in a new tab).
Animations and transitions
Animating top, left, margin, width or height moves neighboring elements and counts as a shift. Animate transform (translate, scale) and opacity, which do not change the layout.
Content loaded with JavaScript
For a product list, recommendations or reviews loaded afterwards: display a placeholder at the final size (skeleton), or render the content on the server. A “Show more” button triggered by the visitor does not count toward CLS.
WordPress
Versions WordPress 6.0 to 7.1.
WordPress adds width and height to Media Library images inserted into content. The shifts come from elsewhere:
- logos and images hard-coded in the theme without dimensions;
- sliders and page builders that calculate their height in JavaScript;
- ad and cookie banner plugins that insert themselves at the top of the page;
- lazy loading plugins that strip the dimension attributes;
- fonts loaded by the theme without a display strategy.
Optimization plugins (WP Rocket, Perfmatters, LiteSpeed Cache) offer to add missing dimensions to images: enable the option, then check the HTML they produce.
Shopify
Versions Online Store 2.0 themes, Shopify admin, November 2026.
The image_tag filter writes width and height automatically: use it instead of hand-written img tags. Watch out for app blocks (reviews, cross-sells, countdown timers) injected after loading: reserve a minimum height for them in the section's CSS, or move them below the fold. Give the announcement bar a fixed height.
Next.js
Versions Next.js 13 to 16 (App Router).
next/imagerequireswidthandheight, or thefillprop inside a sized container: either way, the space is reserved.next/fonthosts the font and generates the adjusted fallback font:
import { Inter } from 'next/font/google';
const inter = Inter({ subsets: ['latin'], display: 'swap' });
export default function RootLayout({ children }) {
return (
<html lang="fr" className={inter.className}>
<body>{children}</body>
</html>
);
}
- Give a height to the loading state of components loaded on demand and of
Suspenseboundaries.
Common mistakes
- Setting
widthandheight, then forgettingheight: autoin CSS: the image is distorted on mobile, and the temptation is to remove the attributes. - Testing only the top of the page: shifts while scrolling count just as much.
- Collapsing an empty ad slot: that is one more shift.
- Inserting the cookie banner into the flow at the top of the page.
- Loading a font very different from the fallback font without adjusting the metrics.
- Relying on your own visit: with a warm cache and a fast connection, the shifts disappear. Test with the cache cleared and the network throttled.
- Reserving the same fixed pixel height on every screen: on mobile, the final block does not have the same height. Use
aspect-ratioor values per breakpoint.
Frequently asked questions
How is CLS calculated?
Each unexpected shift gets a score that combines the share of the screen affected and the distance the elements move. CLS does not add up every shift in the visit: it keeps the largest burst, a window of closely spaced shifts lasting at most five seconds. It has no unit, and Google rates it good at 0.1 or less for at least 75% of visits.
Why is my CLS good in Lighthouse but poor in the field?
Lighthouse only measures shifts during loading, without scrolling or interaction. Real visitors, on the other hand, scroll through the page, receive real ads and respond to the cookie banner. A lab CLS of zero with a poor field CLS therefore points to late shifts: lazy-loaded images without dimensions, ads, banners or content inserted while scrolling.
Do web fonts cause layout shifts?
Yes. When the web font replaces the fallback font, line width and height change and the text shifts. Host fonts as WOFF2 on your own domain, preload the one used by the text visible first, and bring the fallback font's metrics closer with size-adjust and the override descriptors. The font-display: optional value removes any shift, at the cost of the web font on a slow first visit.
Does CLS affect rankings?
A modest effect, like the other Core Web Vitals, and no documented effect on generative engines. The clearest benefit is for visitors: no more jumping text while reading, fewer accidental taps on an ad or a neighboring button. It is also the easiest Core Web Vital to fix for good, since reserving space for late elements is almost always enough.
Resources
- web.dev: Cumulative Layout Shiftweb.dev
- web.dev: Optimize CLSweb.dev
- web.dev: Debug layout shiftsweb.dev
- MDN: aspect-ratio propertydeveloper.mozilla.org
- MDN: size-adjust descriptordeveloper.mozilla.org
- Next.js: Font optimizationnextjs.org
- Shopify: image_tag filtershopify.dev
Updated on
Topic checklist (PDF)