How to Fix Mobile-Friendly Rendering and Horizontal Scroll
This check fails when pages are missing a viewport meta tag containing width=device-width, or when the page scrolls horizontally on a 390px-wide phone screen. By the end of this guide, every key template will declare a responsive viewport. You will also have found and fixed the specific elements that push content past the screen edge.

Why it matters
Google indexes the mobile version of your pages, so a layout that breaks on phones is the version that gets evaluated. Without width=device-width, mobile browsers render a 980px desktop canvas and shrink it, which leaves text unreadable and tap targets tiny. Horizontal scrolling causes misclicks, hides content off-screen and raises bounce rates.
It also tends to hurt Core Web Vitals such as CLS. The check fails once 10% or more of your audited pages have either problem, which usually points to one broken template rather than many separate issues.
What you need
Step-by-step fix
Identify failing pages and their templates
Open each URL from your audit report and group them by template, for example all /products/ pages or all /blog/ posts. Problems almost always come from a shared template or component. For each template, run the console snippet below on one page to check the viewport tag and detect horizontal overflow.
Before running it, open DevTools (F12), toggle the device toolbar (Ctrl+Shift+M / Cmd+Shift+M) and set the width to 390.
const vp = document.querySelector('meta[name="viewport"]');
console.log('Viewport:', vp ? vp.content : 'MISSING');
console.log('Horizontal scroll:', document.documentElement.scrollWidth > document.documentElement.clientWidth, document.documentElement.scrollWidth + 'px vs ' + document.documentElement.clientWidth + 'px');Add the responsive viewport meta tag
Place this tag inside the <head> of your base layout, so every page inherits it. The content must include width=device-width, which is the value the audit looks for. Make sure there is only one viewport tag; duplicates from a theme plus a plugin can conflict.
Do not add maximum-scale=1 or user-scalable=no. 4.
<meta name="viewport" content="width=device-width, initial-scale=1">
Find the exact elements causing overflow
With the device toolbar still at 390px, paste this snippet into the Console. It outlines in red every element that extends beyond the viewport and logs it, so you can click straight to it in the Elements panel. Work from the outermost flagged element inward, because one wide parent often makes all of its children appear flagged.
const vw = document.documentElement.clientWidth;
document.querySelectorAll('body *').forEach(el => {
const r = el.getBoundingClientRect();
if (r.width && (r.right > vw + 1 || r.left < -1)) {
el.style.outline = '2px solid red';
console.log(Math.round(r.left), Math.round(r.right), el);
}
});Fix the common overflow causes in CSS
Most horizontal scroll comes from a few patterns:
- Fixed pixel widths such as width: 1200px or min-width on wrappers
- Media without max-width, including images, videos, iframes and embeds
- Wide tables and code blocks
- width: 100vw, which includes the scrollbar width
- Long unbroken strings such as URLs, emails or SKUs
- Negative margins on full-bleed sections
Add the rules below to your global stylesheet, then replace fixed widths with max-width plus width: 100%.
img, video, iframe, embed, object, svg { max-width: 100%; height: auto; }
.container, .wrapper { width: 100%; max-width: 1200px; box-sizing: border-box; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
pre, code { white-space: pre-wrap; overflow-wrap: anywhere; }
p, li, td, a { overflow-wrap: anywhere; }
.full-bleed { width: 100%; } /* instead of width: 100vw */
.row { flex-wrap: wrap; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }Constrain third-party embeds and widgets
Chat widgets, cookie banners, ad slots, map iframes and social embeds often inject fixed widths. Use the per-provider settings below, or override the container. For YouTube or map iframes, drop the hard-coded width attribute and use aspect-ratio so the embed scales down.
If an ad slot is fixed at 728px, serve a mobile size such as 320x100 below 768px.
<div style="max-width:100%;"> <iframe src="https://www.youtube.com/embed/VIDEO_ID" style="width:100%;aspect-ratio:16/9;border:0;" loading="lazy" allowfullscreen></iframe> </div>
Test every key template on real devices
Emulation misses some issues that only real devices show, including iOS Safari's dynamic toolbar, font rendering and the on-screen keyboard. For each template, load a live page on a real iPhone and a real Android phone. Try to swipe left and right; the page should not move sideways.
Then test the menu, forms, product galleries and any tables, and rotate to landscape and back.
Re-run checks and confirm the fix
Deploy and clear any page cache or CDN cache. Then rerun the step 1 snippet on one URL per template; you should see the viewport content and 'Horizontal scroll: false'. Run Lighthouse (DevTools > Lighthouse > Mobile) and confirm the viewport audit passes.
Finally, rerun this site audit to confirm fewer than 10% of pages are flagged, and ideally none.
npx lighthouse https://example.com/products/sample --only-audits=viewport --form-factor=mobile --screenEmulation.width=390 --view
Platform-specific notes
WordPress
Most modern themes output the viewport tag through wp_head(). If it is missing, add it in Appearance > Theme File Editor > header.php just before wp_head(), or use a child theme. Block themes include it automatically. Overflow often comes from page-builder sections with fixed widths: in Elementor, check Responsive Mode and set mobile widths to 100%.
Shopify
Go to Online Store > Themes > ... > Edit code > layout/theme.liquid and confirm the viewport tag sits in <head>. Online Store 2.0 themes include it by default. Horizontal scroll usually comes from custom sections, app blocks or product-description HTML pasted with inline width styles. Edit those sections, or override them in assets/base.css.
Wix
Wix adds the viewport tag automatically, and you cannot edit it. Fix overflow in the Mobile Editor by switching to the mobile view and resizing or hiding elements that extend past the gridlines. Custom Embed/HTML iframe elements must be resized separately for mobile.
Webflow
Webflow adds the viewport tag automatically. In the Designer, select the Mobile Portrait breakpoint (478px and below) and look for elements with fixed widths, 100vw values or negative margins. Use the Navigator to find hidden elements that still take up width, and set overflow on the specific section rather than the Body.
Next.js
The App Router adds width=device-width, initial-scale=1 automatically. To customise it, export const viewport = { width: 'device-width', initialScale: 1 } from app/layout.tsx. In the Pages Router, add the meta tag via next/head in pages/_app.js, not in _document.js.
Check that it worked
✅ How to verify
- In Chrome DevTools at 390px width, run document.documentElement.scrollWidth > document.documentElement.clientWidth on one page per template. It should return false.
- View the page source (Ctrl+U) and search for name="viewport". There should be exactly one tag, and it should contain width=device-width.
- Run a mobile Lighthouse report and confirm the 'Has a <meta name="viewport">' audit passes.
- Swipe sideways on a real iPhone and Android phone on each key template. The page should not shift horizontally.
⚠️ Common mistakes
- Adding overflow-x: hidden to html or body to hide the scrollbar. The content is still cut off, sticky positioning can break, and the underlying layout bug remains.
- Using width: 100vw for full-width sections. On browsers with visible scrollbars this is wider than the visible area and creates a small sideways scroll.
- Adding user-scalable=no or maximum-scale=1 to the viewport tag. This blocks zoom for users with low vision.
- Testing only the homepage, while product, blog or landing templates with tables, embeds or long URLs still overflow.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
Does Google still have a Mobile-Friendly Test tool?
No. Google retired the Mobile-Friendly Test and the Search Console Mobile Usability report in December 2023. Use Chrome DevTools device emulation, Lighthouse's mobile audits and testing on real devices instead. Google still uses mobile-first indexing.
Why test at 390px wide?
390 CSS pixels matches common current iPhone widths and is close to typical Android widths. A layout that fits at 390px without sideways scrolling will generally work on most phones. Also check 360px, the narrowest common Android width, to be safe.
What does width=device-width actually do?
It tells the mobile browser to set the layout width to the device's screen width in CSS pixels. Without it, phones render a virtual 980px-wide page and zoom out, so your responsive media queries never trigger.
Is it OK for tables to scroll sideways on mobile?
Yes, as long as the scrolling happens inside the table's own container rather than the whole page. Wrap the table in a div with overflow-x: auto so readers can swipe the table while the rest of the page stays in place.
How to Fix JavaScript-Dependent Content for Crawlers and AI
How to Fix Web Font Loading with font-display and Preload
How to Fix Crawl Budget Waste from URL Parameters
How to Fix Third-Party Script Impact on Your Homepage
How to Fix Duplicate URL Variants (Case, Slash, Index)
How to Fix Unused JavaScript and Speed Up Mobile Pages