Home  ›  Blog

How to Fix Mobile Horizontal Scroll Overflow in CSS (2-Minute Fix)

Hand holding a smartphone showing a website that fits the screen
One element wider than the screen is all it takes — find it, fix it, and the sideways scroll is gone.

If your website slides sideways on a phone, one element on the page is wider than the screen. Find that element, fix its width, and the sideways scroll is gone — usually in about two minutes, with a few lines of CSS and no rebuild. The usual culprits are a fixed-width box, an image with no max-width, a long email address or web address that cannot wrap, a footer grid that refuses to stack, or a wide table or code block. Below is the check, the exact way to find the culprit, and the fix for each cause — including the three we found on our own site in November 2026.

Want us to fix it for you? Every site we build is checked on a real phone before it goes live — see our custom web development service.

First, check it on a real phone in 2 minutes

Do not start in code. Start on your phone, the way a customer sees the site.

  1. Open your homepage on your phone and try to swipe it left and right. If the page moves sideways at all, you have the problem.
  2. Check a second page — your contact page, or any page with a table, a price list or a long email address. The homepage can be clean while another page overflows.
  3. Check a small screen, not just your own phone. Many Android phones are 360 pixels wide, and the accessibility standard is 320. A page that fits your phone can still break on a cheaper one.

If you have a laptop nearby, there is a one-line test in Chrome DevTools. Open the page, press F12, go to the Console tab and paste document.documentElement.scrollWidth > window.innerWidth. If it returns true, something on the page is wider than the screen. If it returns false, the page fits — test another page.

Google used to warn you about this: its Search Console Mobile Usability report flagged pages with "content wider than screen". But Google retired that report, the Mobile-Friendly Test tool and its API on 1 December 2023 (Google Search Central blog). Nobody emails you about it now — the two-minute phone check is the warning system.

Find the one element that sticks out

A page scrolls sideways because of one element — usually just one — that refuses to shrink. The fix is not to squeeze the whole page. It is to find that element and fix its width.

Paste this one line into the DevTools console on your own page. It lists every element whose right edge passes the edge of the screen:

[...document.querySelectorAll('body *')].filter(el => el.getBoundingClientRect().right > window.innerWidth)

The list can be long, because a wide parent makes its children stick out too. Ignore the children. Fix the outermost element — the one whose parent still fits inside the screen. That is the element setting the width. Bugviso's October 2026 test of 188 homepages found 5.9% scrolled sideways at 390 pixels, doubling to 12.2% at 360 pixels — a common Android width.

No laptop? Ask your developer to run the line and send you the name of the outermost element. You do not need to understand the code to act on the answer.

A person holding a smartphone next to a laptop showing the same website
The same site on a phone and a laptop — the phone is where the overflow shows up.

The 6 causes — and the fix for each

Almost every case is one of these six. Match what you found to the row, apply the fix, and re-check on the phone.

CauseHow to spot itFix
No viewport meta tagThe whole page looks tiny, like a desktop site shrunk downAdd <meta name="viewport" content="width=device-width, initial-scale=1.0"> in the <head>
Fixed-width elementA box set to a pixel width, e.g. width: 960pxChange it to max-width: 100% so it can shrink
Image with no max-widthA photo or banner wider than the phoneimg { max-width: 100%; height: auto; }
Long email or web addressA long address with no spaces that cannot wrapoverflow-wrap: anywhere on the container, or show a shorter address
Footer or grid that will not stackThree columns side by side on a phone screenStack to one column under 960px, or use grid-template-columns: repeat(3, minmax(0, 1fr))
Wide table or code blockA price table or code sample running off the edgeWrap it in a container with overflow-x: auto — it scrolls inside its own box, not the page

Not sure which row is yours? Get an instant estimate for a mobile layout fix — most take less than an hour of work.

How we fixed it on our own site

In November 2026 our own site, metaprime.online, scrolled sideways on phones. The cause was not one thing — it was three, and all three were pre-existing, not caused by any new feature.

After those three fixes the sideways scroll was gone. The cause is almost never the whole page — it is one or two elements, each with a small, specific fix. That is why we check every site on a real phone before it goes live: a desktop browser hides this problem completely.

What not to do: overflow-x: hidden is a band-aid

The most common advice online is to add overflow-x: hidden to the page. It stops the sideways movement — by cutting off whatever sticks out. The content past the edge is still there, just unreachable: a button nobody can tap, an address nobody can read.

It also fails the accessibility standard: WCAG 2.2 Success Criterion 1.4.10 (Reflow) asks for content that works at 320 CSS pixels wide without scrolling in two directions. Hiding overflow does not make content fit — it makes it disappear. Bugviso's October 2026 test found 13.3% of homepages already hid overflow this way.

Use it only as a temporary guard while you fix the real cause — never as the fix itself. On our own site we keep it only below 640 pixels as a safety net, after fixing the three causes above.

Why it matters: the numbers

Phones are not a side channel any more. StatCounter put mobile at 59.9% of worldwide web page views in October 2026, against 38.5% for desktop — and in the United States mobile was 45.4% (StatCounter Global Stats, October 2026). If your layout breaks on a phone, a large share of your visitors only ever see the broken version.

A visitor who has to scroll sideways to read your phone number or tap your button usually just leaves — they cannot see what slid off-screen and will not pinch and drag to find it. If the page is also slow, the damage doubles: our guide to sub-0.8s page speeds covers the weight side, and heavy JavaScript hurts the same pages on Core Web Vitals, as our Core Web Vitals guide explains.

The 5-minute checklist

Run it on every page that matters, and repeat it after every deploy — new images and embeds are the usual repeat offenders.

  1. Open the site on a real phone. Swipe sideways on the homepage and the contact page.
  2. Run the scrollWidth check at 360 pixels and at 320 pixels in DevTools.
  3. Run the element-finder line. Note the outermost element that sticks out.
  4. Match it to the table above and apply the fix.
  5. Re-check on the phone. Repeat until nothing moves sideways.
  6. After every future change, check again before it goes live.

If the page still scrolls after the table fixes, the cause is usually an absolutely positioned decoration, a slide-out menu, or an embedded map or video with a fixed width — the same finder line will name it. Send the name to your developer with this checklist; the fix is usually a one-line change. Or send us the link on WhatsApp and we will tell you which element it is.

Frequently asked questions

Why does my website scroll sideways on mobile?
One element on the page is wider than the phone screen — a fixed-width box, an image with no max-width, a long email address, a footer grid that will not stack, or a wide table. Find the outermost element with the console line in this guide and fix its width.

Is overflow-x: hidden a proper fix for horizontal scroll?
No. It hides the symptom by cutting off whatever sticks out, so buttons and addresses past the edge become unreachable. It also fails WCAG 2.2 Reflow (1.4.10). Fix the element that is too wide instead, and use overflow-x: hidden only as a temporary guard.

How do I find which element causes horizontal scroll?
In Chrome DevTools, paste [...document.querySelectorAll('body *')].filter(el => el.getBoundingClientRect().right > window.innerWidth) into the console. It lists every element past the right edge — fix the outermost one, whose parent still fits.

What does “content wider than screen” mean?
It was Google's Search Console error for a page wider than the phone screen. Google retired that report, the Mobile-Friendly Test tool and its API on 1 December 2023, so you now find it yourself with the two-minute phone check in this guide.

Can I fix horizontal scroll without a developer?
If the cause is a missing viewport tag or an image with no max-width, yes — the fixes in the table are a few lines of CSS. If your theme or builder will not let you edit CSS, send your developer the outermost element name and this checklist.