Cumulative Layout Shift From Cookie Banners, Fonts and Embeds: Fixes
Short answer: Cumulative Layout Shift (CLS) measures how much visible content moves without the visitor causing it. On small business sites the usual offenders are a consent banner that pushes the page down, images without dimensions, web fonts that swap in at a different size, and embeds (maps, videos, review widgets) that load late with no reserved space. Find the shifting elements in Chrome DevTools, turn the banner into a fixed overlay, give every image and embed a fixed box, match the fallback font's metrics with size-adjust, and then wait for real-user data to confirm the score has dropped below 0.1.
What counts as a layout shift
Google's definition in the web.dev CLS guide is about unexpected movement: an element that changes position between two frames when the user has not just clicked, tapped or typed. Movement within a short window after an interaction is excluded, so an accordion opening on click does not count against you. A banner that appears two seconds after load and shoves the heading down does.
A "good" score is 0.1 or less at the 75th percentile of page loads. Anything above 0.25 is rated poor.
Finding the shifting elements in DevTools
Before fixing anything, see what actually moves:
- Open the page in Chrome, press F12 and go to the Performance panel.
- Tick Screenshots, then click the reload-and-record button. Stop when the page has settled.
- In the Layout shifts track (or the "Experience" row in older versions), each shift appears as a block. Click one to see the nodes that moved and their before and after positions.
- For a live view, open the command menu (Ctrl+Shift+P or Cmd+Shift+P), run Show Rendering, and tick Layout Shift Regions. Shifting areas flash blue as the page loads.
- Run Lighthouse in DevTools as well; its "Avoid large layout shifts" audit lists the worst elements.
Repeat on a throttled mobile profile. Shifts that are invisible on fast office broadband often appear on a phone connection because fonts and banners arrive later.
Cookie banners: overlay, not push-down
Consent banners cause a lot of avoidable shifting on UK sites, because they are injected by a script after the page has rendered. If the banner is inserted at the top of the body in normal document flow, everything beneath it slides down.
Fixes, in order of preference:
- Position it as an overlay. Use
position: fixedwithbottom: 0(or a centred modal). A fixed element sits above the page and does not move the content, so it creates no layout shift. - Check the consent tool's settings. Most consent platforms offer "bar at bottom" or "popup" layouts. Avoid "push content down" or "top bar inline" options.
- Avoid animating layout properties. Slide the banner in with
transform: translateY()rather than animatingtop,heightormargin, which change layout. - Load it early. If a top bar is non-negotiable, render its container in the server HTML with a fixed height so the space exists from the first paint.
The same logic applies to promotional bars ("Free delivery over 50 pounds") added by marketing apps.
Images: width, height and aspect ratio
An image without dimensions takes up zero height until it downloads, then pushes everything below it. Give every img element width and height attributes that reflect its intrinsic ratio, for example width="1200" height="800". Modern browsers use those numbers to compute an aspect ratio and reserve the right amount of space, even when CSS makes the image responsive with width: 100%; height: auto.
For images set by CSS or in a page builder that will not output dimensions, wrap them in a container with aspect-ratio: 3 / 2 or a fixed min-height.
Web fonts: font-display and size-adjust
When a web font loads after the fallback font has already rendered, text reflows if the two fonts have different widths or line heights. A heading that wrapped onto two lines in Arial can need three in the brand font, pushing the page down.
Ways to reduce the jump:
- Preload the main font file with
<link rel="preload" as="font" type="font/woff2" crossorigin>so it arrives before first render more often. - Choose
font-displaydeliberately.swapshows text immediately but can shift;optionaluses the web font only if it is ready almost instantly, which removes the shift on slow connections at the cost of sometimes showing the fallback. - Match fallback metrics. Define a fallback
@font-facethat points to a local font and adjust it withsize-adjust,ascent-override,descent-overrideandline-gap-overrideso it occupies the same space as the web font. The MDN reference page for thesize-adjustdescriptor shows the syntax. Several font tools can calculate these values for common pairs. - Self-host fonts rather than fetching them from a third-party stylesheet, which adds an extra connection before the font can even start downloading.
Embeds and ad slots: reserve the space
Maps, YouTube videos, booking widgets, Instagram feeds and review carousels usually arrive via JavaScript, long after the surrounding text.
- Wrap each embed in a sized container. For a 16:9 video,
aspect-ratio: 16 / 9; width: 100%on the wrapper. For a map, a fixed height such as 400px. - Use a placeholder. A static image of the map or a video thumbnail with a play button (a "facade") reserves space and also speeds up the page, loading the real embed only when clicked.
- Size dynamic widgets to their typical height. If a review widget usually shows three reviews at about 320px, set
min-height: 320pxon its container. - Do not inject content above existing content after load, such as "Related offers" blocks inserted above the article.
More patterns are covered in the web.dev guide to optimising CLS.
Verifying in field data
Lab tools load the page once, in ideal conditions, and only measure shifts during load. Real visitors scroll, wait and see late banners. Confirm your fixes where it counts:
- Run the URL through PageSpeed Insights. The top section, "Discover what your real users are experiencing", shows field CLS from the Chrome UX Report when your site has enough traffic.
- In Search Console > Core Web Vitals, find the URL group that was failing and click Validate fix once the changes are live.
- Allow about four weeks. Field data is a rolling 28-day window, so the score improves gradually rather than overnight.
FAQ
Does CLS affect my rankings?
Core Web Vitals are one of many signals Google uses, and good content still matters far more. A stable layout mainly helps visitors who would otherwise click the wrong thing as the page jumps.
My Lighthouse CLS is 0 but Search Console says poor. Why?
Lighthouse only measures during load. Real users trigger shifts later, for example a banner appearing after a delay or content loading as they scroll. Use the Layout Shift Regions view while scrolling to find these.
Is a fixed cookie banner allowed under UK consent rules?
Layout does not change your consent obligations. A fixed overlay can present the same choices as an inline bar. Check the ICO's guidance on cookies for what the banner must offer.
If your CLS score refuses to improve and you would like a second pair of eyes on the template, send us the URL and we will look at what moves.