Cumulative Layout Shift
Quick summary
Elements on your page move after initial render because their dimensions are not reserved — images, fonts, or ads load and push content around.
Why this happens
Images without width and height attributes
Web fonts loading and causing text to reflow
Dynamically injected content (ads, banners) pushing existing content
CSS animations that change element dimensions
Minimal example
<!-- No dimensions — causes layout shift when image loads -->
<img src="hero.jpg" alt="Hero"><!-- Width and height reserve space immediately -->
<img src="hero.jpg" alt="Hero" width="800" height="600">
<!-- Or use CSS aspect-ratio -->
<img src="hero.jpg" alt="Hero" style="aspect-ratio: 4/3; width: 100%;">Without width/height, the browser does not know how much space to reserve. When the image loads, it pushes content down. Specifying dimensions reserves the space immediately.
How to diagnose
Run Lighthouse and check the CLS (Cumulative Layout Shift) score
Observe the page loading slowly — note which elements move
Check images for missing width/height attributes
How to fix
Always specify width and height attributes on images and videos
Use font-display: swap or optional in @font-face
Reserve space for dynamic content with min-height or aspect-ratio
Use CSS transform for animations instead of changing layout properties
How to prevent
Always include width and height on media elements
Use aspect-ratio CSS to reserve space for responsive media
Preload critical fonts to reduce font swap time
Related Resources
Related Lessons
- Web Performance
Performance and layout stability.