How to Debug Layout Problems with Core Web Vitals

A screenshot can make a tutorial page look perfectly aligned and still hide a layout bug. Say the browser puts a code example near the top of the page, then an illustration loads above it. If the browser hasn’t reserved space for the illustration, the code jumps down. Both look fine in the finished screenshot. To catch the bug, you need to see what happened while the page was loading.

Three metrics, three different clues

Core Web Vitals tell you how soon the main content appears, how quickly the page responds to input, and how much visible content shifts unexpectedly. Each metric gives you a place to look, but none tells you which component to fix.

  • Largest Contentful Paint (LCP): 2.5 seconds or less is good. LCP measures how long it takes, after navigation starts, for the largest eligible image or block of text in the viewport to render. On a wide screen, that might be the tutorial illustration. On a phone, it might be the introduction. Check which element the browser measured before you change anything.
  • Interaction to Next Paint (INP): 200 milliseconds or less is good. INP reflects how long the browser takes to paint the next frame after a click, tap, or key press. It represents one of the slowest interactions during a visit. When there are many interactions, some outliers are excluded. If a navigation drawer is slow to open, JavaScript could be holding it up, the browser could be spending time recalculating the layout, or both.
  • Cumulative Layout Shift (CLS): 0.1 or less is good. CLS is a unitless score for unexpected movement of visible elements. It’s based on the worst burst of shifts during a visit, not the total of every shift. If a note appears above a paragraph and pushes it down, the paragraph’s movement can count toward CLS even though there’s nothing wrong with the paragraph itself.

In field reports, each metric is evaluated separately at the 75th percentile. If mobile LCP is good at that percentile, at least three quarters of measured mobile visits met the LCP threshold. That doesn’t mean everyone had a fast load, or that those same visits also met the INP and CLS thresholds.

Find what moved before changing the CSS

Before you edit any templates or styles, back up the working version or commit it to version control so you can restore it. Then reproduce the problem on a staging page or in a local copy. Use the same content and fonts as the live page if you can. A short placeholder article may not reveal a bug that only appears when a heading wraps or a wide code sample doesn’t fit.

  1. Start at the viewport width where you see the problem. If the field data looks worse on mobile, start with a narrow viewport. If the page changes columns or rearranges its navigation at a breakpoint, test just above and just below it.
  2. Record a reload in your browser’s Performance panel. Turn on screenshots if they’re available. Try a cold load by disabling the cache while DevTools is open. A slower connection can make the shift easier to spot. Find the layout shift entries and compare the frames just before and after each one.
  3. Look above what moved. The trace might flag a heading and a code block without pointing to the late-loading banner that pushed them down. Inspect nearby containers. Did an image gain height? Did a font swap change where the text wraps? Did a script insert a block?
  4. Record another trace while you use the page. Scroll far enough to bring lazy-loaded illustrations into view, open a code example, and try the navigation near the breakpoint. Test resizing separately. A reload trace can miss problems that show up only after you start using the page.

For a responsive image, set the HTML width and height attributes to the image file’s intrinsic dimensions. Then let the image shrink without distortion with CSS such as max-width: 100%; height: auto;. That gives the browser enough information to reserve space before the image loads. For an embed with a known aspect ratio, set aspect-ratio on its wrapper. If the shift happens when a web font loads, check whether the fallback font wraps the same headings onto a different number of lines. A fallback with closer font metrics can cut down on movement without leaving extra space under every heading.

Some visible movement doesn’t count toward CLS. A shift within 500 milliseconds of a qualifying input, such as a click to open an accordion, is normally excluded. But if the click fetches content that arrives later and pushes the page down, that shift can still count. Scrolling alone doesn’t trigger the exclusion.

Developer inspecting a page at mobile width

Use LCP to check what gets space at the top

Select the LCP event in a load trace and see which element it points to. If it’s a large banner above the tutorial title, ask whether the banner helps the reader start the lesson. A decorative image that takes up most of a phone screen can get in the way even if it loads quickly. A wiring diagram the reader needs to follow the first step may deserve that space.

Once you know which element was measured, use the trace to see where the time went. Did the browser discover it late, spend a long time downloading it, or wait to render it? An image inserted by JavaScript may go unnoticed until the script runs. Even if the image is in the initial HTML, lazy loading can delay it when it’s already in view. If the download finishes well before the image appears, look at what happened in between. Styles might still be loading, or a script might be keeping the browser busy. Moving an illustration down the page just to make something else the LCP element can improve the score without helping the reader.

Use INP to test layout changes triggered by input

When a tutorial’s “Show solution” button feels slow, the browser might already be busy when you click. The button’s event handler might be doing too much, or the browser might need time to lay out and paint the expanded section. Profile the click before you blame the handler.

Record the interaction and inspect the work before the next paint. One pattern to look for is a handler that changes a style, reads a measurement such as offsetHeight, then repeats those two steps for several elements. The browser may have to recalculate the layout before each read. If you can take all the measurements from the original layout, read them first and apply the style changes together. If syntax highlighting takes most of the time, changing the layout won’t fix the main delay. Check when the highlighter runs and how much code it processes.

Verify the fix without treating the scores as a design review

Lab recordings help you reproduce a problem. Field data shows what happens during real visits, where devices, connections, and the way people use the page can vary. In PageSpeed Insights, check whether the field report covers the exact URL or the whole origin. An origin-level result can reflect several templates, so it doesn’t prove the tutorial you tested has the same issue. Public field reports also use a rolling 28-day window. A fix you deployed yesterday won’t immediately replace the older measurements. A standard Lighthouse navigation run is useful for diagnosing load problems, but its Total Blocking Time doesn’t measure INP directly.

Three good scores won’t tell you that a menu clips its labels, a code block makes the whole page scroll sideways, or an overlay covers the next instruction without moving it. Check those separately. If you fixed a late-loading diagram above a code sample, repeat the cold-load trace at the width where the bug appeared. Then try a narrower viewport and increase text zoom. Check that the diagram’s space is there before it loads and that long lines scroll inside the code block instead of widening the page.