web development

How to Decrease Cumulative Layout Shift (CLS)

Improve Your Website’s Visual Stability and User Experience


What Is Cumulative Layout Shift (CLS)?

Cumulative Layout Shift (CLS) measures how much elements on your webpage move unexpectedly while it’s loading.
It’s one of Google’s Core Web Vitals, along with Largest Contentful Paint (LCP) and First Input Delay (FID).

A low CLS score means your website feels stable and smooth. A high CLS score means users see elements jumping around — a frustrating experience that can hurt conversions and search rankings.

Google recommends keeping CLS below 0.1 for optimal performance.


Why CLS Matters

  • User Experience: Shifting buttons and text can make visitors click the wrong element — leading to frustration.

  • SEO Ranking: CLS directly affects your Core Web Vitals, which are part of Google’s ranking signals.

  • Professionalism: A stable, polished site feels more trustworthy and well-built.


Common Causes of Poor CLS

  1. Images and videos without dimensions

  2. Ads or embeds loading dynamically

  3. Fonts swapping or flashing on load

  4. Late-loading banners, popups, or cookie notices

  5. Dynamic content injected above existing elements


Step-by-Step: How to Decrease CLS

1. Always Set Width and Height for Images and Videos

When browsers know the exact dimensions, they reserve the correct space before loading the media.
This prevents content from shifting downward once the image loads.

✅ Example:

<img src="hero.jpg" alt="Website example" width="1200" height="600">

Modern CSS can also help:

img { aspect-ratio: 2 / 1; }

2. Reserve Space for Ads and Embedded Content

Ads or embedded YouTube videos can cause major shifts when they appear later.

✅ Fix:

  • Use a fixed container height for ads or embeds.

  • If ad size varies, use the largest possible height to prevent sudden jumps.

<div style="min-height: 250px;">
<!-- Ad code loads here -->
</div>

3. Load Fonts Properly

When custom web fonts load late, text may “flash” or shift (known as FOUT or FOIT).

✅ Fix:

  • Use font-display: swap; in your CSS.

  • Preload key fonts for faster rendering.

@font-face {
font-family: 'Inter';
src: url('/fonts/inter.woff2') format('woff2');
font-display: swap;
}

4. Avoid Injecting Content Above the Fold

Never insert banners, popups, or forms at the top after the main content loads — it pushes everything down.

✅ Fix:

  • Insert new elements below existing content or overlay them instead.

  • Use lazy loading wisely: load below-the-fold content after initial render.


5. Preload Important Elements

Preloading large images, fonts, and critical CSS ensures your layout is ready before anything moves.

✅ Fix:

<link rel="preload" as="image" href="hero.jpg">
<link rel="preload" as="style" href="styles.css">

6. Use CSS Instead of JavaScript for Layouts

When possible, use CSS Grid or Flexbox layouts instead of dynamic JS scripts.
JS-driven elements often shift positions after DOM rendering.

✅ Tip:
Keep animations and layout transitions subtle — and avoid layout-affecting motion during load.


7. Measure and Monitor CLS

You can’t fix what you don’t track. Use free tools like:

Check your “Cumulative Layout Shift” score and note which elements move, then fix those specific cases.


Pro Tips to Improve CLS Without Breaking Design

  • Use CSS aspect-ratio to keep your layout flexible.

  • Preload above-the-fold assets first.

  • Use lazy loading for below-the-fold images only.

  • Test your site on mobile; CLS issues often appear more there.

  • Reduce third-party scripts and unnecessary widgets.


Ideal CLS Targets

CLS Score Performance
0.00 – 0.10 Excellent
0.10 – 0.25 Needs Improvement
> 0.25 Poor

Final Thoughts

Improving Cumulative Layout Shift isn’t just about pleasing Google; it’s about creating a stable, trustworthy, and enjoyable user experience.

By setting image dimensions, reserving space for ads, preloading assets, and controlling font behavior, you can dramatically improve your CLS score without sacrificing design quality.

A stable website looks professional, performs better in search, and builds trust with every scroll.

54121381948 41948871 706385425 82712804 318798 199621147 5207418
Ad - Web Hosting from SiteGround - Crafted for easy site management. Click to learn more.

Here, we dive deep into the transformative world of business and website development, offering insightful articles, success stories, expert tips, and the latest trends that matter to you.

How to make a website book

Get In Touch

We would love to hear from you, and we answer every email we receive. So drop us a line!

Fulgsi
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.