Fix horizontal overflow on a mobile website
A page that slides left and right on a phone can make session times, location details and ticket actions hard to follow. First decide whether the whole document is wider than the screen or a single schedule table is intentionally scrollable. This guide gives website editors and developers a repeatable way to locate the cause, choose a content-preserving fix, and retest the exact page.
Boletolibre editorial team
Published
1. Reproduce the sideways movement
Open the failing URL at a narrow viewport, then drag sideways on the ordinary page background. If the header, text and ticket button all move, the document may be wider than the viewport. If only a timetable or map moves inside its own boundary, record that separately: some content has a legitimate two-dimensional layout. Note the exact viewport width, browser, zoom level and whether the problem appears before or after a widget loads.
- Check the same page at about 320 and 375 CSS pixels, plus a wider phone width; do not assume one device represents every layout.
- Repeat in portrait and landscape, and use desktop zoom or text enlargement to expose a narrow effective viewport.
- Record which edge disappears first: poster, session title, price, venue detail, menu or booking button.
W3C's Reflow criterion uses a width equivalent to 320 CSS pixels for vertically scrolling content, with an exception for parts that require two-dimensional layout. Treat that as an accessibility check, not a promise that every phone has a 320-pixel screen. A screenshot and the first clipped element give the person fixing the site a useful starting point.[1]
2. Isolate the element, not just the scrollbar
Inspect the page section by section at the failing width. A wide poster, fixed-width session card, unbroken URL, calendar embed or ticket widget can extend the document. In browser developer tools, compare the document's scrollable width with the viewport, then inspect elements that cross either viewport edge and their parents. Temporarily hide or outline one suspect section to confirm it is responsible; restore it before publishing.
| What you see | Likely place to inspect next |
|---|---|
| The entire page pans sideways | A child element or fixed-width container extending past the document edge |
| Only the schedule grid moves | Whether a deliberate local scroll preserves all rows, headings and controls |
| The problem begins after loading | A third-party iframe, ticket widget, late image or injected banner |
| Only one long line causes it | A URL, code, title or no-wrap rule that cannot break within its card |
Do not make overflow-x: hidden on html or body the first fix. That rule can suppress visible sideways movement while leaving a link or purchase control clipped; verify that it is still reachable. MDN explains that hidden overflow clips content, though focus can sometimes scroll hidden content into view. First identify why the child is too wide and whether the full content can reflow.[2]
3. Repair the cause at its own boundary
Use the smallest layout change that preserves the information. A media width rule is different from a word-breaking rule; neither solves a fixed-width third-party widget by itself. Test the component after each change rather than applying several global CSS rules at once.
| Cause | Safer first change | Check after the change |
|---|---|---|
| Poster, image or video exceeds its parent | Constrain rendered media to its container, for example with max-width: 100% and automatic height. | The full relevant image stays visible and does not distort. |
| Card or grid track refuses to shrink | Review fixed widths and the flex/grid item's automatic minimum; a suitable item may need min-width: 0. | Text and buttons wrap without overlap. |
| Long ticket URL or unspaced text | Give the text a sensible wrapping opportunity, such as overflow-wrap: anywhere for the affected field. | The label remains readable and its link still works. |
| Iframe or vendor ticket widget is too wide | Use the vendor's responsive display or a container that fits the page; test the embedded interaction at narrow widths. | Price, consent and checkout controls remain usable. |
| Dense multi-column timetable | Stack each session as a card where possible, or contain the table's horizontal scroll inside a clearly bounded area. | No document-wide panning is needed to read ordinary text. |
MDN documents responsive media sizing, flex/grid minimum widths and overflow-wrap behavior. The examples above are starting points, not a stylesheet to paste everywhere: a fixed minimum may protect a map or control for a reason, and changing it without inspecting the component can introduce a new defect.[5][3][4][6]
4. Keep deliberate scrolling local and understandable
Not every horizontal scroll is a failure. W3C names data tables, maps and diagrams among content that can require two-dimensional layout. If a timetable truly needs columns side by side, keep that scrolling within the table region while the surrounding event information reflows. Make the region recognizable, keep headers available, and check that a keyboard user can reach its content and controls.[1]
An event card, paragraph, date label or ticket call to action normally has no such need. If hiding overflow makes a button vanish, the visual symptom has been concealed, not repaired. Avoid disabling browser zoom as a workaround: people who enlarge content need the same schedule and checkout path. Where a provider embed cannot fit, offer a separate, clearly labeled link to the provider's full page and verify that destination.[2]
- Keep the page's main reading path vertical at narrow widths.
- For a necessary scrollable table, verify the first and last columns and every control are reachable by touch and keyboard.
- Do not crop meaningful poster text, venue information or booking controls to remove a scrollbar.
5. Retest the real attendee task
After the fix, repeat the same viewport and zoom conditions that exposed the issue. Move from event details to agenda to ticket or registration handoff. Test a long translated title and the longest real session name, because short sample text can hide the problem. Confirm that page-level sideways movement is gone without replacing it with clipped content or overlapping controls.
- At a width equivalent to 320 CSS pixels, ordinary text and controls reflow without two-direction reading.
- The poster, timetable, ticket widget and any local scroller remain fully usable.
- Keyboard focus reaches every visible action in a sensible order; no focused item disappears behind a clip.
- Portrait, landscape and a second browser or device show the same essential information.
- Record the page, viewport, suspected component, fix owner and before/after result.
If a vendor widget still overflows, send its provider a narrow-viewport example and keep a verified full-page alternative visible. The worksheet below separates the original symptom from the actual element and records the retest, so a future design change does not reintroduce the issue.
Download the mobile overflow diagnostic worksheet (Markdown, English)
Sources and further reading
- W3C WAI: Understanding ReflowW3C Web Accessibility Initiative · Accessed
- MDN: overflow CSS propertyMDN Web Docs · Accessed
- MDN: min-width CSS propertyMDN Web Docs · Accessed
- MDN: overflow-wrap CSS propertyMDN Web Docs · Accessed
- MDN: Responsive web designMDN Web Docs · Accessed
- web.dev: Responsive imagesweb.dev · Accessed