CLS Image Layout Shift: Why It Happens and How to Fix It

Contents
You've probably seen it: an image loads late, and the content below it suddenly jumps down the page. This has a name — CLS (Cumulative Layout Shift) — and a clear cause. The browser doesn't know the image's size until the file downloads.
Summary ① If an image has no width or height set, the browser only learns its real size after the download finishes — and the layout shifts at that moment (CLS). ② If you declare the size up front with the HTML width and height attributes or CSS aspect-ratio, the browser reserves the space before the image loads. ③ If the final image isn't ready yet, you can drop in a placeholder image with the same pixel dimensions to check for and prevent the shift.
Why the screen shifts after images load
When the browser draws a page, it calculates the space each element takes from top to bottom. If an <img> tag has no size information, the browser reserves almost zero space for it and only learns the actual pixel width and height once the image file has fully downloaded.
At that moment, the browser recalculates the layout to make room for the image. Any text or buttons below it get pushed down by that amount — and CLS, one of the Core Web Vitals Google introduced, is the metric that measures how big those shifts are.
This is worse on slow connections, like mobile. A paragraph you're reading jumps and you end up tapping the wrong button — a common experience on pages with high CLS.
How to prevent the shift: try it yourself
The most reliable fix is to put the real size on the image tag in advance. Set the pixel width and height, like width="1200" height="630", and the browser reserves space at that ratio before it even downloads the file. CSS's aspect-ratio property does the same job.
The problem is when the final image isn't ready yet. During design mockups or development, you need something to hold the spot instead of the real photo — and if the size doesn't match, the layout shifts all over again the moment you swap in the real image.
In that case, create a temporary image with the exact same pixel width and height as the final image and put it in place first. You can do this in an image editor by creating a new canvas at the size you want, filling it with a background color, and saving it.
Check it with our tool. Instead of opening an image editor and creating a canvas every time, just enter the width and height and download an image at exactly that size.
Free · no signup · runs in your browser only (nothing is sent to a server)

The size values and label shown on screen are pixels drawn into the image itself, so if you put this file in place, the width and height of that spot stay exactly right until you swap in the real image.
Common sticking points
| Situation | What actually happens |
|---|---|
No width or height on <img> at all | The browser draws without knowing the size, and the layout shifts when the image finishes loading |
| Placeholder size differs from the final image | The layout shifts again by that difference when you swap in the real image |
| width and height set, but not matching the real ratio | The image can look stretched or squished |
| Using only CSS aspect-ratio and skipping width and height | Modern browsers reserve the space, but if you need to support older ones, add the attributes too |
The bottom line
The CLS jump after images load comes from one simple fact: the browser doesn't know the image size in advance. Set the pixel width and height on the <img> tag, or specify CSS aspect-ratio, and most cases are solved.
During development or design, when the final image doesn't exist yet, putting a placeholder image of the same size in its place is enough to keep working without any layout shift.
Free · no signup · runs in your browser only (nothing is sent to a server)
Frequently asked questions
What happens if I set width and height but the real image has a different ratio?
The browser reserves space based on the width and height you set, but if the original image has a different ratio, CSS can make it look stretched or squished. Space reservation is separate from that — set the size to match the final image's ratio, and the layout won't shift and the image won't distort.
If I use CSS aspect-ratio, can I skip the width and height attributes?
In modern browsers, aspect-ratio alone reserves the space before the image loads. But some older browsers don't support the property, so if you need broad compatibility, it's safer to include the width and height attributes as well.
Do the size and label text stay on the downloaded file?
Yes. The text you see on screen is drawn onto the canvas and saved as-is into the PNG, JPG, or WebP file, so it's baked into the image when you open the download. Before using it in production, replace it with the real image that doesn't have that text.
How do I check how much the screen is shifting?
Enter your page URL in the Lighthouse panel of Chrome DevTools or in Google PageSpeed Insights, and it reports the CLS score along with which elements caused the shifts. Compare the score before and after you set image sizes, and you'll see the effect right away.
This article was adapted from our Korean original. Read the Korean original