How to Eliminate Cumulative Layout Shift (CLS) and Stop Your Page Jumping
## The short answer
Cumulative Layout Shift (CLS) happens when content moves unexpectedly while a page loads or runs. You eliminate it by reserving space for everything that arrives late: set explicit dimensions on images, videos and embeds; reserve space for ads and dynamically injected content; avoid inserting content above existing content; and prevent fonts from causing reflow. A good CLS score is 0.1 or lower at the 75th percentile of real users. Every fix comes down to one principle — never let an element push other elements out of the way after the user can see them.
## What CLS actually measures
CLS scores the unexpected movement of visible elements. The score for each shift is the fraction of the viewport affected multiplied by the distance things moved, and the metric reports a representative session window. Crucially, it only counts *unexpected* shifts — movement within 500ms of a user interaction is excused, because users expect the page to respond when they click.
## Cause 1: Images and media without dimensions
The most common cause. When an image has no declared width and height, the browser does not know how much space to reserve, so text and other elements jump down when the image finally loads.
Fixes:
- Always set `width` and `height` attributes (or an `aspect-ratio` in CSS) so the browser reserves the correct space.
- Apply the same discipline to `
- For responsive images, the aspect ratio is preserved automatically when width and height are present, so the reserved box scales correctly.
## Cause 2: Ads, embeds and iframes
Advertising slots are notorious for CLS because they load late and at variable sizes. To control them:
- Reserve a fixed-size container for each ad slot, sized to the most common dimensions.
- Avoid placing ads near the top of content where a shift moves the most material.
- If an ad collapses to nothing when unfilled, style the container so it does not collapse and re-shift.
## Cause 3: Dynamically injected content
Banners, cookie notices, "you may also like" blocks and lazy-loaded sections all cause shifts if they appear above content the user is already reading.
Rules of thumb:
- Never insert content above existing content unless it is in response to a user action.
- Reserve space for content you know is coming.
- Render notices in an overlay rather than pushing the page down.
## Cause 4: Web fonts
Fonts cause two kinds of shift: invisible text that then appears (FOIT) and a fallback font that then swaps to the web font with different metrics (FOUT), nudging the layout.
Mitigations:
- Preload your primary web fonts so they arrive sooner.
- Use `font-display: swap` to avoid invisible text.
- Match fallback font metrics to the web font using `size-adjust` and related descriptors so the swap causes minimal reflow.
## Cause 5: Animations that affect layout
Animating properties like `top`, `height` or `margin` forces the browser to recompute layout and can register as a shift. Animate `transform` and `opacity` instead — they are composited and do not move surrounding content.
## How to find your worst shifts
Diagnosis tools make this concrete:
1. **PageSpeed Insights** lists the specific elements contributing to CLS.
2. **Chrome DevTools' Performance panel** highlights layout shift events with the offending nodes.
3. **The Web Vitals browser extension** lets you watch shifts happen in real time as you scroll and interact.
Fix the largest contributor first; CLS is dominated by a small number of big shifts far more often than by many tiny ones.
## Don't forget interaction-driven layout
A subtle trap: shifts that happen *because* of an interaction are excused only within a 500ms window. If your accordion or filter takes longer than that to settle, the resulting movement counts against you. Make interactive expansions fast and, where possible, reserve their space too.
## Why this matters commercially
Layout shift is not just a metric — it causes misclicks, accidental purchases, and abandoned forms, all of which erode trust and conversion. Treating visual stability as a quality bar across templates, rather than fixing pages one at a time, scales far better. Enterprise teams bake these checks into their build pipeline, which is the philosophy behind the products neart.ai builds in this area.
## Practical takeaway
CLS is the most fixable Core Web Vital because the cause is almost always missing reserved space. Go through your templates and ensure every image, video, embed, ad slot and font has its space reserved before it loads. Fix the single largest shift first, confirm in field data, and you will usually clear the 0.1 threshold quickly.