
Cumulative Layout Shift (CLS) measures how much the content of a page jumps around unexpectedly while it loads and while people use it. A good score is 0.1 or less for at least 75 percent of visits. The most common causes are images and videos without dimensions, ads and embeds without reserved space, web fonts swapping, and banners or cookie notices injected above content. This guide explains how CLS is calculated, how to find exactly which element is shifting, and the code fixes for each cause.
- Good CLS is 0.1 or less; above 0.25 is poor. Google measures it from real Chrome users.
- Always give images, videos and iframes
widthandheightattributes, or a CSSaspect-ratio. - Reserve space for ads, embeds, sliders and late-loading banners before they arrive.
- Animate with
transformandopacity, never withtop,heightormargin.
Cumulative layout shift: what CLS measures and how it is scored
Every time a visible element moves from where it was rendered in one frame to a different position in the next, without the user causing it, the browser records a layout shift. Each shift gets a score: Also, this is one of the easiest ways to fix cumulative layout shift.
layout shift score = impact fraction × distance fraction
- Impact fraction: how much of the viewport the unstable elements cover, before and after the move combined.
- Distance fraction: how far they moved, relative to the viewport's largest dimension.
Shifts are grouped into session windows: shifts less than one second apart, up to five seconds per window. The page's CLS is the score of the worst window, not the total over the whole visit, so long pages are not unfairly punished.
| CLS | Rating |
|---|---|
| 0 to 0.1 | Good |
| 0.1 to 0.25 | Needs improvement |
| Above 0.25 | Poor |
Shifts that happen within 500 milliseconds of a tap, click or key press are excluded, because users expect the page to change when they interact. Scrolling does not count as an input for this purpose.
Lab vs field CLS: why scores differ
Lighthouse and PageSpeed Insights' lab section only measure shifts during page load, in a single simulated visit. Field data (the Chrome UX Report shown at the top of PageSpeed Insights and in Search Console's Core Web Vitals report) includes shifts that happen later, for example when a user scrolls and lazy-loaded ads appear. That is why a page can score 0 in Lighthouse and still fail CLS in Search Console. For an overview of all three Core Web Vitals, see our speed testing guide. So keep this in mind whenever you fix cumulative layout shift.
Cumulative layout shift: how to find the element that shifts
- PageSpeed Insights: under Diagnostics, open "Avoid large layout shifts" to see the elements and their contribution.
- Chrome DevTools Performance panel: record a page load; layout shifts show as purple bars in the "Layout shifts" track. Click one to highlight the moving element.
- Rendering panel: in DevTools, open More tools → Rendering and enable "Layout Shift Regions" to flash shifted areas blue as you scroll.
- Console snippet: paste this to log every shift and the nodes involved while you scroll and click:
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.hadRecentInput) continue;
console.log(entry.value.toFixed(4),
entry.sources.map(s => s.node));
}
}).observe({ type: 'layout-shift', buffered: true });
Test on a throttled mobile connection. Many shifts only appear when fonts and images load slowly.
Fix 1: Give images and videos dimensions
An image without dimensions takes up zero height until it downloads, then pushes everything below it down. Add the intrinsic width and height attributes; modern browsers use them to compute the aspect ratio before the file arrives, even when CSS makes the image responsive. In short, it is one of the simplest ways to fix cumulative layout shift.
<img src="team.webp" width="1200" height="800" alt="Our team"
style="max-width:100%; height:auto">
For containers whose content arrives later, such as video embeds or background-image heroes, reserve space with aspect-ratio:
.video-wrap { aspect-ratio: 16 / 9; width: 100%; }
.video-wrap iframe { width: 100%; height: 100%; }
WordPress adds width and height to images inserted through the editor automatically. Problems usually come from page builders, sliders and custom theme code. See our image size guide for the right dimensions.
Fix 2: Reserve space for ads, embeds and dynamic content
Ads, social embeds, review widgets and "related products" blocks often load after the page and insert themselves into the flow. Give their container a minimum size based on the most common size it will receive: In fact, small steps like this are how you fix cumulative layout shift.
.ad-slot { min-height: 250px; } /* 300×250 unit */
@media (min-width: 768px) {
.ad-slot-top { min-height: 90px; } /* 728×90 leaderboard */
}
- Do not collapse the slot if no ad fills; show a placeholder instead.
- Place dynamic blocks lower on the page where possible, because shifts near the top move more content.
- For embeds such as Instagram posts or Google Maps, set a fixed height or aspect ratio on the wrapper.
Fix 3: Stop web fonts from shifting text
When a custom font loads, text re-renders in the new font. If the fallback font has different widths or line heights, lines rewrap and the page jumps. Fixes, in order of impact:
- Preload the one or two font files used above the fold:
<link rel="preload" href="/fonts/inter-var.woff2"
as="font" type="font/woff2" crossorigin>
- Self-host fonts in WOFF2 instead of loading them from a third-party server, so they arrive sooner.
- Match the fallback to the web font's metrics with
size-adjustand override descriptors:
@font-face {
font-family: "Inter Fallback";
src: local("Arial");
size-adjust: 107%;
ascent-override: 90%;
descent-override: 22%;
line-gap-override: 0%;
}
body { font-family: "Inter", "Inter Fallback", sans-serif; }
- Use
font-display: optionalif you prefer no swap at all on slow connections; the font is used from the next page view once cached.
Next.js (next/font) and some WordPress performance plugins generate matched fallbacks automatically.
Fix 4: Cookie notices, top bars and late banners
A promotional bar or app banner inserted at the top of the page after load pushes the whole page down, which is one of the largest shifts possible. Options:
- Render it in the HTML from the start, so it is part of the first layout.
- Overlay it with
position: fixedat the bottom of the screen instead of inserting it into the flow. - Reserve its height in CSS until the script decides whether to show it.
Fix 5: Use transform-based animations
Animating properties such as top, left, height, width or margin moves other elements and counts as layout shift. Animating transform and opacity does not, and it is smoother because the GPU handles it.
/* Causes layout shift */
.panel.open { height: 300px; transition: height .3s; }
/* No layout shift */
.toast { transform: translateY(100%); transition: transform .3s; }
.toast.show { transform: translateY(0); }
Fix 6: Late-loading content and skeletons
Pages that fetch content with JavaScript (product grids, price widgets, reviews) should render skeleton placeholders at the final size, then swap in the real content in place. Also check:
- Infinite scroll and "Load more" should add content below the viewport, not above it.
- Sliders and carousels should have a fixed height before their script initialises.
- Pages restored from the back/forward cache (bfcache) avoid shifts entirely, so do not block bfcache with
unloadevent handlers.
Cumulative layout shift: CLS fixes for WordPress sites
- Check slider plugins and page builders for missing image dimensions; many lazy-load images without width and height.
- Do not lazy-load the hero image. It should load immediately, which also helps LCP.
- If a caching plugin offers "delay JavaScript", test it carefully; scripts that build layout (menus, sliders) can cause large shifts when delayed.
- Preload fonts and disable Google Fonts loading from the theme if you self-host them.
Cumulative layout shift: CLS checklist
| Check | Fix |
|---|---|
| Images, videos, iframes without dimensions | Add width and height, or aspect-ratio |
| Ads and embeds pushing content | min-height on the slot |
| Text jumping when fonts load | Preload, self-host, metric-matched fallback |
| Top banners inserted after load | Render early, overlay, or reserve space |
| Animations moving other content | Use transform and opacity |
| JavaScript-rendered sections | Skeletons at final size |
Cumulative layout shift: frequently asked questions
Cumulative layout shift: does CLS affect Google rankings?
CLS is one of the three Core Web Vitals used in Google's page experience signals. It is a small factor compared with content relevance, but it directly affects how usable the page feels, especially on phones.
Why does Search Console show poor CLS when Lighthouse shows zero?
Search Console uses real-user field data that includes shifts after load, such as when people scroll. Lighthouse only measures the initial load in a lab.
How long until Search Console shows the improvement?
Field data is a rolling 28-day average, so expect about four weeks after the fix. Use "Validate fix" in the Core Web Vitals report to track it.
Do lazy-loaded images cause CLS?
Only if they have no dimensions. Lazy-loaded images with width and height reserve their space and do not shift.
Related guides: 404 Error, 403 Forbidden Error and ERR_TOO_MANY_REDIRECTS.
For official guidance, see web.dev by Google.
Want your Core Web Vitals fixed?
Our speed and performance optimization service finds and fixes CLS, LCP and INP problems on WordPress and custom sites. Also read our guides to good page load times and speeding up WordPress, or contact us.
Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.
Ask a Question on WhatsApp