How to Fix Cumulative Layout Shift and Image Size Problems
Published · 6 min read
Platform details checked against official documentation on November 10, 2026.
To fix Cumulative Layout Shift (CLS), give every image and video a width and height, reserve space for anything that loads late (embedded videos, maps, ads, cookie banners, review widgets), and stop web fonts from changing the size of your text after it appears. Then retest with Google's PageSpeed Insights. On most small business websites, images without dimensions and late-loading banners cause most of the shift.
What the problem is
Cumulative Layout Shift measures how much the content of a page jumps around while it loads. You have probably experienced it: you go to tap a button, an image finishes loading above it, the button drops down, and you tap something else.
CLS is a score, not a time. According to web.dev, a score of 0.1 or less is good, and anything above 0.25 is poor. Google measures it at the 75th percentile, so most visits need to be good for the page to pass.
Why it matters
The main reason is your visitors: a page that moves under someone's finger leads to wrong taps and abandoned forms, especially on phones.
CLS is also one of Google's three Core Web Vitals, along with loading speed (Largest Contentful Paint) and responsiveness (Interaction to Next Paint). Google says "Core Web Vitals are used by our ranking systems," but also that good scores don't guarantee top rankings and that it "always seeks to show the most relevant content, even if the page experience is sub-par." Fix it for the people using your site; treat any search benefit as a bonus.
How to find what is moving
- Run PageSpeed Insights on your homepage, using the mobile results.
- Read the two kinds of results separately. The top section, if it appears, is field data: how the page performed for real Chrome users over the previous 28 days. Below it is lab data: a single simulated load on one device. Small sites often have no field data, so the lab test is all you get.
- Find the layout-shift item in the diagnostics or insights list. It names the elements that moved and how much each one contributed.
- Watch it happen. Open the page on your phone on a slower connection, or reload it a few times on a computer, and watch for content that jumps.
How to fix it, step by step
1. Give images a width and height
The most common cause is an image with no size in the code. The browser doesn't know how much room to leave, so text appears first and is pushed down when the image arrives. web.dev's advice is to "always include width and height size attributes on your images and video elements." Use the image's real pixel size:
<img src="/images/team.jpg" alt="Our team outside the Springfield office" width="1200" height="800">Modern browsers use those two numbers to work out the image's shape and reserve the right space before it downloads. To keep the image responsive on small screens, pair it with this CSS:
img {
max-width: 100%;
height: auto;
}Since version 5.5, WordPress adds width and height automatically to images inserted from the Media Library. Problems usually come from images added in custom HTML, page-builder widgets or theme backgrounds.
2. Reserve space for embeds
YouTube videos, Google Maps, booking tools and review widgets often load inside an iframe that starts with no height. Give the container its shape up front:
.video-embed {
width: 100%;
aspect-ratio: 16 / 9;
}
.video-embed iframe {
width: 100%;
height: 100%;
border: 0;
}For widgets whose height you know only roughly, such as a review carousel, set a min-height close to its usual height so the content below doesn't move much when it appears.
3. Don't push content down after the page loads
Cookie notices, promotional bars and "we're hiring" banners that slide in at the top of the page push everything below them. Either reserve their space from the start, or show them as an overlay fixed to the bottom of the screen, which doesn't move other content.
4. Tame web font swaps
When a custom font loads, text can change size and rewrap. web.dev notes that font-display: optional "can avoid a re-layout," at the cost of sometimes showing the fallback font. If you use a hosted font service, check its settings for a "font display" option. If you self-host fonts, set it in the @font-face rule:
@font-face {
font-family: "Brand Sans";
src: url("/fonts/brand-sans.woff2") format("woff2");
font-display: optional;
}Fixing oversized image files
Image dimensions and image file size are different problems. Dimensions in the code prevent layout shift. File size affects how long the page takes to show its main content, which is the Largest Contentful Paint score. Both often turn up in the same report.
- Resize before uploading. A photo straight from a phone can be 4,000 pixels wide. If it displays at 1,200 pixels, export it at that size.
- Compress it. Save photos as WebP or a well-compressed JPEG. Most website builders also offer automatic compression; make sure it is turned on.
- Lazy-load images further down the page with
loading="lazy", but not the main image at the top. Delaying the first image a visitor sees makes the page appear slower.
How to check that it worked
- Rerun PageSpeed Insights and compare the lab CLS with your earlier result. Run it two or three times, because lab results vary between runs.
- Wait for field data to catch up. Real-user results cover the previous 28 days, so improvements take weeks to show fully.
- Check the pages people actually land on, not just the homepage. Service pages and blog posts often use different templates.
Common mistakes and limitations
- Setting width and height, then overriding them in CSS with a fixed height that doesn't match the image's shape. That distorts the image.
- Fixing the lab score only. Lab tests measure the page while it loads. Real visitors can also experience shifts later, for example when a widget expands after scrolling, and those count in field data.
- Chasing a perfect zero. Anything at or under 0.1 is good. Spend the remaining effort on content.
- Looking only at the theme. Shifts often come from things added on top of it, such as embeds, banners and third-party scripts.
Related reading
Page speed is one of several things that affect how your site appears in search. See also how to fix a missing meta description and how to make your address and phone number visible.
Sources
- web.dev: Cumulative Layout Shift (CLS)
- web.dev: Optimize Cumulative Layout Shift
- web.dev: Largest Contentful Paint (LCP)
- Google Search Central: Understanding page experience in Google Search results
- Google for Developers: About PageSpeed Insights