Overview
CLS (Cumulative Layout Shift) is the Core Web Vital for visual stability. A layout shift happens when a visible element changes position between two frames; its score is the impact fraction (share of the viewport affected) multiplied by the distance fraction (how far it moved). CLS reports the largest burst, a session window of shifts less than one second apart and at most five seconds long.
Good is 0.1 or less, needs improvement is up to 0.25, and poor is above 0.25, at the 75th percentile of page loads. Shifts within 500 ms of a discrete user input (click, tap, key press) are excluded; scrolling and pinching are not.
Fix it by reserving space before content loads:
- Set
widthandheighton images, video, and iframes, or use CSSaspect-ratio. - Give ads, embeds, banners, and cookie notices a reserved
min-height, and do not inject them above existing content. - Preload critical fonts and use
font-displaywith a size-adjusted fallback (size-adjust) so text does not reflow on swap. - Animate with
transform, nottop,left,width, orheight.
Example
<img src="hero.jpg" alt="Hero" width="1200" height="600">.ad-slot { min-height: 90px; } /* reserve space for the late-loading ad */Related
- core-web-vitals: the metric set CLS belongs to.
- core-web-vitals: measurement and debugging workflow.
- html: image and iframe dimension rules.
- css:
aspect-ratioand reserved space. - lcp: the loading metric, scored separately.
- inp: the responsiveness metric, scored separately.