Layout Shift (CLS)
Unexpected visual movement of rendered page elements during load—measured by Cumulative Layout Shift (CLS)—often causing misclicks
Table of Contents
Structure Diagram
What is Layout Shift (CLS)?
Unexpected visual movement of rendered page elements during load—measured by Cumulative Layout Shift (CLS)—often causing misclicks. It is a core concept in Motion & Interaction within UI / UX.
Core Principles
Layout Shift occurs when visible content unexpectedly jumps during page load—typically because unsized images, late-loading ads, injected banners, or web fonts change element dimensions after initial paint. Google's Core Web Vitals tracks this via Cumulative Layout Shift (CLS), targeting 0.1 or lower for a Good rating.
Beyond hurting SEO, layout shifts cause frustrating misclicks (such as tapping a shifted button by mistake) and erode perceived product quality.
Practical Takeaways
- Reserve space upfront for media and ads: Always set
width/heightor CSSaspect-ratioon images and embeds, and lockmin-heighton dynamic ad or banner slots. - Tame web font metric shifts: Pair
font-display: swapwith fallback font metric overrides (size-adjust, ornext/font's automatic fallback generation) so line wrapping does not jump when custom fonts load. - Prefer
transformfor motion: Animatingtransformnever triggers layout shifts, whereas animatingheight,top, ormarginpushes surrounding content and inflates CLS.
Notable Examples
- Late-injected ad banners: The classic anti-pattern where a header ad loads after 1 second and shoves an article off screen.
- Dimension-matched skeletons: Matching skeleton card heights and aspect ratios to real content to hold CLS near
0.00. - Overlay notifications: Rendering dynamic alerts in fixed toast layers rather than inserting blocks above already-rendered text.