CLS Issues Caused by Images: How to Fix Layout Shifts
Images are the #1 cause of Cumulative Layout Shift (CLS). Learn how to reserve space using CSS aspect-ratio and width/height attributes.
Why Do Images Jump?
Google recommends reserving space for images to prevent layout shifts and improve CLS.
CLS is a Core Web Vitals metric, and poor CLS can negatively affect Page Experience signals, which are used as a ranking factor in Google Search.
Ideal for: Frontend Developers and Web Designers.
Last updated: Jan 2026
TL;DR (Quick Fix)
- Reserve Space: Always set
widthandheightattributes.- Use CSS:
aspect-ratio: 16 / 9;preserves space before load.- Avoid: Inserting ads or banners dynamically without a placeholder container.
You load a page, start reading, and suddenly the text snaps down 500 pixels because a large banner image finally loaded. This is Cumulative Layout Shift (CLS), and Google hates it.
What is a Good CLS Score?
Google’s performance standards are precise:
- Good: ≤ 0.1
- Needs Improvement: 0.1 – 0.25
- Poor: > 0.25
To pass Core Web Vitals, you need a score of 0.1 or less.
The Fix: Reserve Space Before Images Load
The browser doesn't know how much space an image needs until its dimensions or aspect ratio are defined. To fix this, you must tell the browser the aspect ratio before the image loads.
Old Way (HTML Attributes)
Always include width and height attributes:
<img src="hero.jpg" width="800" height="600" alt="Hero">
Browsers use this to calculate the aspect ratio (800/600 = 1.33) and reserve the vertical space immediately.
Modern Way (CSS Aspect Ratio)
.hero-image {
aspect-ratio: 16 / 9;
width: 100%;
height: auto;
}
Before vs After: CLS Fix in Practice
Here is a real-world example of how one CSS line fixes a failing score.
| Scenario | Code State | CLS Score | Result |
|---|---|---|---|
| Before | Image loads without dimensions | 0.32 | ❌ Fails Core Web Vitals |
| After | Added aspect-ratio: 16/9 |
0.02 | ✅ Passes (Perfect Layout) |
Common Mistakes to Avoid
- Lazy Loading Without Reserved Space: Lazy loading images without width/height or an aspect ratio causes the browser to assume zero height until the image loads.
- Dynamic Ads: Inserting banner ads mid-content without a container
divof fixed height. - Image Carousels: Sliders that change height for every slide cause massive shifts.
Tools to Help
- Aspect Ratio Calculator: Find the perfect ratio dimensions for your responsive slots.
- Image Resizer: resizing images to exact dimensions ensures they fit their containers perfectly.