Orofold Labs

Launching soon

Notes Get in touch

Performance and accessibility 4 min read Updated

Fixing Cumulative Layout Shift without jumping content

In short

Give every element its space before it loads, because content that arrives late and pushes the page is the usual cause of layout shift.

A button that jumps just as a visitor reaches for it is a layout shift. Cumulative Layout Shift (CLS) measures how much visible content moves unexpectedly while a page loads and while it is used. If you want the score lower, first find the element that moved, and only then reserve space for it or move the new content lower down.

Start with the target

A CLS of 0.1 or less is rated good, and above 0.25 is poor. Values in between need improvement. Aim for 0.1 or less on at least 75% of page visits. Unlike LCP and INP, CLS has no unit of time. It is a score, not a duration.

The score combines content and distance

The score has two components: how much visible content moves, and how far it travels. Both count, so a large element that moves a little and a small element that jumps a long way can each raise the score. Treat the number as a prompt to investigate, and find the element that moved before you change anything.

Reserve space for images and video

The most common fix is to give every image and video element width and height attributes. The browser then works out the aspect ratio before the file loads and holds the space. MDN describes the same mechanism: the attributes let the browser reserve the space needed, which limits or prevents the layout shift when the image is painted. If you cannot add the attributes, the CSS aspect-ratio property can reserve the space instead. In responsive images, every candidate in the srcset should share one aspect ratio.

Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea

Reserve space for ads and embeds

Content that arrives after the first paint, such as an advertisement, a video embed or a banner, needs a reserved place. Use min-height or aspect-ratio. If the final size varies, reserve the smallest expected size, so that the shift from a larger item stays limited. Do not collapse the reserved space when the content fails to arrive. Show a placeholder instead, because removing the space can cause as much shift as inserting the content.

Place new content with care

Content inserted near the top of the viewport usually causes larger shifts than content lower down, so place late-loading elements lower on the page wherever you can. Banners at the top or bottom of the screen need reserved space, a skeleton placeholder, or an overlay that does not push the page. Where possible, load new content after a user action, such as a Load more button, rather than automatically.

Fonts can move the layout too

Web fonts are a common hidden source of shifts. Text is first laid out in a fallback font, so when the web font arrives and replaces it, the text can change size and position. Use font-display: optional where layout stability matters most, so that the web font is applied only if it is ready at first layout. Choose a fallback of similar size, reduce the difference with size-adjust and related overrides, and preload the most important font file. The article on web fonts covers the trade-offs.

Six checks to run

  1. Use the layout shift information in your browser’s performance tools to see which elements move.
  2. Check that every img and video has width and height attributes, or a CSS aspect-ratio.
  3. Reserve space for every ad, embed and banner before it loads.
  4. Move late-loading content lower on the page, or load it after a user action.
  5. Check that the fallback font is close to the web font in size.
  6. Test on a narrow screen, where images scale and the layout changes most.

Images also affect the largest element on the page, see Responsive images that fit the screen and the layout. For fonts in more detail, read web fonts without slowing the page or moving the text. The wider context of speed is in speed as part of design.

Common questions

Do images need width and height if they use CSS?
The guidance recommends width and height attributes on images and video, or reserving the space with the CSS aspect-ratio property. Either approach lets the browser allocate the space before the file loads.
Should I reserve space for an ad that may not load?
Yes. Reserve the smallest expected size and show a placeholder if the content does not arrive. Collapsing the space can cause as much shift as inserting late content.
Why does text move when the font loads?
Text is laid out in a fallback font first. When the web font arrives and replaces it, the text can change size and position. Font-display optional and a fallback of similar size reduce this effect.

Sources

  1. Optimize Cumulative Layout Shift, web.dev (Google). Accessed 24 November 2026
  2. img: The Image Embed element, MDN Web Docs (Mozilla). Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes