# Eliminate unintended horizontal scrolling

- Check 07.03 · Mobile-first and responsive design · Critical
- Source: https://checklist-seo-geo.com/en/mobile-first-responsive-design/eliminate-unintended-horizontal-scrolling
- Find the element that makes the page overflow on mobile and fix it in CSS: images, tables, iframes, 100vw, flexbox, off-screen menus, by environment.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/mobile-first-responsive-design/eliminate-unintended-horizontal-scrolling.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Unintended horizontal scrolling appears when an element is wider than the screen: the page “floats” left and right under the finger, a white strip appears on the side, and part of the content is cut off. Fixing it means finding the culprit element and constraining it to the available width, without hiding the problem with a global `overflow-x: hidden`. Once the task is done, every template displays without horizontal scrolling from 320 px up to tablet width, and only content that requires it (a large table, a map, code) scrolls inside its own frame.

## Why it matters

On a phone, visitors scroll vertically. When the page is also wider than the screen, every slightly diagonal vertical swipe shifts it sideways, text slides off the screen and buttons placed on the right become invisible. If the viewport tag is correct, the browser does not zoom out to show everything: the content that sticks out is simply out of view.

WCAG criterion 1.4.10 (Reflow, level AA) requires that content can be read at a width of 320 CSS pixels without scrolling in two directions, except for content that requires a two-dimensional layout, such as data tables, maps or diagrams.

For search engines, the text stays in the HTML: an overflow does not prevent indexing. But Google indexes the mobile version and assesses page experience; a template that overflows is above all a template that drives mobile visitors away and sometimes hides call-to-action buttons.

## What it improves

- **Readability and navigation**: no more cut-off text or page sliding sideways.
- **Conversion**: buttons placed on the right (cart, submit, menu) become visible again.
- **Accessibility**: compliance with WCAG criterion 1.4.10, also useful for visitors who enlarge text on desktop.
- **Visual stability**: animations that bring blocks in from the edge of the screen stop widening the page, which also removes visible shifts.
- **Rankings**: indirect effect only, through the mobile experience.

## How to check

**On a real phone**: swipe the page to the left. If it moves and reveals an empty strip, it overflows.

**In Chrome**: device toolbar (`Ctrl+Shift+M`), width 320 px then 360 px, and scroll through the whole page. A horizontal scroll bar at the bottom of the simulated page signals an overflow.

**Find the culprit**: paste this script into the console, at the width that causes the problem. It lists the elements that stick out to the right or left of the screen:

```js
(() => {
  const largeur = document.documentElement.clientWidth;
  const fautifs = [...document.querySelectorAll('body *')].filter((element) => {
    const zone = element.getBoundingClientRect();
    return zone.width > 0 && (zone.right > largeur + 1 || zone.left < -1);
  });
  console.log(`Visible width: ${largeur} px, page: ${document.documentElement.scrollWidth} px`);
  fautifs.forEach((element) => console.log(Math.round(element.getBoundingClientRect().right), element));
})();
```

A compliant page shows the same value for the visible width and the page width, and no element listed other than those placed deliberately inside a scrolling frame. Hover over each element listed in the console: Chrome highlights it in the page. Start with the highest one in the tree: its children often overflow because of it.

An additional visual method: temporarily add `* { outline: 1px solid red; }` in the Elements panel; the block that sticks out jumps out at you.

Also check in landscape mode, with the menu open, with the consent banner displayed, and at 200% text zoom on desktop.

## How to implement

### Before you start

The real causes, in order of frequency:

| Cause | Symptom | Fix |
|---|---|---|
| Fixed width (`width: 1200px`, `min-width`) | A whole block sticks out | `max-width` instead of `width`, or relative units |
| Unconstrained image, video or iframe | The media goes off screen | `max-width: 100%; height: auto` |
| Data table | The table widens the page | Scrolling frame around the table |
| URL, email address, very long word, code | A line of text sticks out | `overflow-wrap: anywhere`; scrolling frame for `pre` |
| `width: 100vw` or breaking out of a container with `50vw` | A few pixels too many, especially with a scroll bar | `width: 100%` |
| Negative margins (Bootstrap grid without `.container`) | 12 to 15 px overflow | Put the container back |
| Flexbox or grid child | The column refuses to shrink | `min-width: 0` or `minmax(0, 1fr)` |
| Off-screen menu, slide-in animation from the side | The page widens by the size of the menu | Really hide it, or clip the container's overflow |
| Third-party widget (social network, reviews, map) | Fixed-width iframe | Container with `max-width: 100%` |

A CSS baseline to place at the top of the stylesheet. It fixes most cases without hiding any content:

```css
*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
picture,
video,
canvas,
svg,
iframe,
embed,
object {
  max-width: 100%;
}

img,
video {
  height: auto;
}

p,
li,
td,
th,
figcaption,
blockquote,
h1,
h2,
h3,
h4 {
  overflow-wrap: anywhere;
}

pre {
  overflow-x: auto;
  max-width: 100%;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.flex > *,
.grid > * {
  min-width: 0;
}
```

Keep the `width` and `height` attributes on images: with `height: auto`, the browser keeps the aspect ratio and reserves the space, with no layout shift.

Videos and maps embedded in iframes keep their proportions with `aspect-ratio`:

```css
.embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}
```

Data tables stay tables: wrap them in a scrolling frame that is keyboard-accessible and named:

```html
<div class="table-scroll" role="region" aria-label="Boiler comparison" tabindex="0">
  <table>
    <!-- … -->
  </table>
</div>
```

For grids, prefer `minmax(0, 1fr)` to `1fr`, which does not go below the width of its content:

```css
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
}
```

For a block that must span the full width from inside a narrow container, avoid `width: 100vw`: on desktop, `100vw` includes the vertical scroll bar. Instead, move the block out of the container in the template, or use `margin-inline: calc(50% - 50vw)` combined with `overflow-x: clip` on the `body` element.

For off-screen menus and slide-in animations, clip the overflow at the level of the container concerned with `overflow-x: clip`, which does not create a scroll container:

```css
.site-wrapper {
  overflow-x: clip;
}
```

> **Warning:** `overflow-x: hidden` on `html` or `body` hides the symptom, not the cause. The content that sticks out becomes inaccessible, and on a container, `hidden` creates a scroll container that can stop `position: sticky` from working. Fix the culprit element; keep `overflow-x: clip` for deliberate visual effects.

### WordPress

Versions: WordPress 6.4 and later; Elementor 3 and Divi, November 2026.

The most common causes:

- **Tables**: the WordPress Table block already scrolls inside its frame (`.wp-block-table` has `overflow-x: auto` in core styles), unless the theme overrides these styles. Raw HTML tables, pasted into a Custom HTML block or inherited from the classic editor, do not benefit from it. Add this in `Appearance > Customize > Additional CSS` (classic theme) or in the Additional CSS of the Site Editor's Styles (block theme):

```css
.entry-content > table,
.wp-block-html table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
```

- **“Full width” alignments** in an old classic theme: some themes implement them with `100vw`. Apply the `overflow-x: clip` rule to the theme's main container, or ask the theme developer for a fix.
- **Page builders** (Elementor, Divi): a block with a width in pixels or a negative margin on mobile. Check the per-device settings of the culprit section, in mobile view. In Elementor, entrance animations from the right widen the page before they fire: turn them off on mobile.
- **Content pasted from a word processor**: inline styles `width: 800px` on images or tables. Remove them in the block's code editor.

Clear the cache of the caching plugin and of the CDN after each fix.

### Shopify

Versions: Shopify, all plans, Online Store 2.0 themes (Dawn and its derivatives), November 2026.

Add the baseline rules to the theme's CSS: `Online Store > Themes`, “…” menu, “Edit code”, then the main CSS file in the `assets` folder (`base.css` on Dawn). Overflows often come from tables inserted in product descriptions, review apps or size guides in iframes. “Custom Liquid” or “Custom HTML” sections are another common suspect. Duplicate the theme before editing it.

### PrestaShop

Versions: PrestaShop 8 and 9, Classic and Hummingbird themes.

Feature tables and descriptions entered in the rich text editor are the main culprits. Add the baseline rules to your theme's `assets/css/custom.css` file: PrestaShop loads it for any theme, Classic as well as Hummingbird (the default theme since PrestaShop 9.1) or a child theme; create it if it does not exist. Then clear the cache in `Advanced Parameters > Performance`. Check banner or carousel modules that set a width in pixels.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4, themes derived from Blank or Luma.

Place the rules in your child theme's LESS file, for example `app/design/frontend/Fournisseur/theme/web/css/source/_extend.less` (`Fournisseur` stands for your vendor name), then regenerate the static files (`bin/magento setup:static-content:deploy fr_FR` in production mode, with your store's locale) and clear the cache. CMS blocks and product descriptions containing HTML tables should be wrapped in the scrolling container.

### Drupal

Versions: Drupal 10 and 11, Drush 12 and 13.

Add the rules to your theme's stylesheet (declared in the library of the `mon_theme.libraries.yml` file), then run `drush cr`. In CKEditor 5, tables inserted by editors are the usual source: wrap them in CSS with `.text-content table` displayed as a scrolling block, or use a text filter that adds the container.

### Joomla

Versions: Joomla 5 and 6, Cassiopeia template.

With Cassiopeia, create a `media/templates/site/cassiopeia/css/user.css` file: the template loads it automatically if it exists. Paste the CSS baseline into it. Articles containing tables or iframes pasted from the editor are the first to check.

### Wix

Versions: Wix Editor, all plans, November 2026.

The overflow almost always comes from an element placed partly outside the visible area in the mobile editor, or from a fixed-width HTML embed. Open the mobile editor, find the element touching the edge, and resize or move it. For an embedded element, set its width in its settings.

### Squarespace

Versions: Squarespace 7.1, all plans, November 2026.

Code blocks and fixed-width embeds are the usual causes. Add the baseline in `Website > Website Tools > Custom CSS`, or fix the width in the Code block. Imported tables are better served by the block designed for that purpose than by pasted HTML.

### Webflow

Versions: Webflow Designer, all plans, November 2026.

In the Designer, switch to the “Mobile portrait” breakpoint and use the Navigator panel to find the element that sticks out. Replace widths in `px` with `%` or `max-width`. For a deliberate overflow (animation, decoration), apply the Overflow “Hidden” setting in the Style panel to the parent section that contains the element, rather than to the `Body` element, and check that no sticky (`sticky`) element sits inside it.

### Laravel

Versions: Laravel 11 to 13; Tailwind CSS 3 and 4 or Bootstrap 5.

Overflow is a CSS problem, not a framework one. With Tailwind, the matching utilities are `max-w-full`, `min-w-0`, `overflow-x-auto`, `break-words` and `overflow-x-clip`. For Markdown content or content from a rich text editor, the `@tailwindcss/typography` plugin handles media; add a scrolling container around tables. With Bootstrap, a `.row` must always be inside a `.container` or `.container-fluid`, and tables inside a `.table-responsive`. A Blade component avoids forgetting the container:

```html
{{-- resources/views/components/table-scroll.blade.php --}}
<div class="table-scroll" role="region" aria-label="{{ $label }}" tabindex="0">
    {{ $slot }}
</div>
```

### Symfony

Versions: Symfony 6.4, 7.4 and 8, AssetMapper or Webpack Encore; Bootstrap 5.

Same approach, in the stylesheets managed by AssetMapper or Webpack Encore. In Twig templates that display rich content, wrap the tables:

```twig
<div class="table-scroll" role="region" aria-label="{{ label }}" tabindex="0">
    {{ content|raw }}
</div>
```

Only use `|raw` on content sanitized upstream.

### Next.js

Versions: Next.js 15 and 16 with `@next/mdx`, App Router and Pages Router.

The framework-specific causes: an `Image` component with a fixed width and no `style={{ maxWidth: '100%', height: 'auto' }}`, and MDX content containing tables. Replace MDX's `table` element with a wrapped component:

With `@next/mdx`, this `mdx-components.tsx` file goes at the root of the project (at the level of `app` or `pages`, or inside `src`); it is required with the App Router.

```tsx
// mdx-components.tsx
import type { MDXComponents } from 'mdx/types'

const components = {
  table: (props) => (
    <div className="table-scroll" role="region" aria-label="Table" tabIndex={0}>
      <table {...props} />
    </div>
  ),
} satisfies MDXComponents

export function useMDXComponents(): MDXComponents {
  return components
}
```

### Nuxt

Versions: Nuxt 3 and 4, Nuxt Content 3.

With Nuxt Content, override the table rendering component by creating `app/components/content/ProseTable.vue` (Nuxt 4; `components/content/ProseTable.vue` at the root in Nuxt 3):

```html
<template>
  <div class="table-scroll" role="region" aria-label="Table" tabindex="0">
    <table><slot /></table>
  </div>
</template>
```

### Astro

Versions: Astro 5 to 7.

For Markdown and MDX, wrap tables with global CSS or with an MDX component passed through the `components` prop. Astro's `Image` component generates the `width` and `height` attributes; add `max-width: 100%; height: auto` in the global CSS.

## Common mistakes

- **`overflow-x: hidden` on `body` as the only fix**: the cut-off content stays unreadable, and the problem reappears on another template.
- **Testing only at 375 px**: many overflows only appear at 320 or 360 px.
- **`width: 100vw` for full-width blocks**: a few pixels of overflow on screens with a scroll bar.
- **Removing the table on mobile**: the content disappears from the indexed version. Keep it in a scrolling frame.
- **Forgetting the open-menu state**: a side menu that is closed but positioned off screen widens the page.
- **Fixing the symptom in a single article**: fix the template or the component, so that all content benefits.

## Frequently asked questions

### Why does my site scroll horizontally on mobile?

An element on the page is wider than the screen. The most common causes are a fixed width in pixels, an image or iframe without max-width, a table, a very long URL, a block set to 100vw, a negative margin, or a menu or animation placed off screen. To find it, compare the width of each element with the width of the screen using a script in the developer tools console.

### Should you put overflow-x: hidden on the body?

No, not as a fix. This rule hides the overflow without removing its cause: the content that sticks out becomes inaccessible, and on a container it can stop position: sticky from working. Fix the culprit element with max-width, min-width: 0 or a scrolling frame. To clip a deliberate overflow, such as an animation, prefer overflow-x: clip on the container concerned.

### How do you display a large table on mobile without making the page overflow?

Place the table in a container with overflow-x: auto: the table scrolls on its own, inside its frame, and the page keeps the width of the screen. Give the container a region role, an accessible name and a tabindex so it can be used with a keyboard. The WCAG reflow criterion allows this scrolling for data tables. Avoid removing the table on mobile: its content would disappear from the indexed version.

### Does horizontal overflow hurt SEO?

Not directly: the text stays in the HTML and Google can index it. The effect comes through the mobile experience. A page that slides sideways and cuts off its buttons drives visitors away, and Google assesses page experience among other signals. Fixing the overflow is above all a gain in readability, accessibility and conversion on mobile.

## Resources

- [W3C: Understanding SC 1.4.10 Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html)
- [MDN: overflow property](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow)
- [MDN: overflow-wrap property](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap)
- [MDN: min-width and flex items](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width)
- [web.dev: Learn Responsive Design](https://web.dev/learn/design)
- [Google Search Central: Mobile-first indexing best practices](https://developers.google.com/search/docs/crawling-indexing/mobile/mobile-sites-mobile-first-indexing?hl=en)

Next steps: [ensure legible text size](https://checklist-seo-geo.com/en/mobile-first-responsive-design/ensure-legible-text-size) and [reserve space for media and ads](https://checklist-seo-geo.com/en/performance-core-web-vitals/reserve-space-media-ads).
