# Scanning every page at 320px for horizontal overflow

> WCAG Reflow says content must not scroll sideways at 320 CSS px. A Playwright scan of 156 pages found 4 that overflowed, five causes in all, and an error report that sent me to half-wrong fixes.

- Date: 2026-11-30
- Topics: CSS, Accessibility, Debugging
- Chinese original: https://kbs0830.com/blog/overflow-320-every-page

I found this while changing the email address in the home page Contact section. The new address is 6 characters longer than the old one; at 390px wide the large version touches the right edge of the screen with only 5px to spare, and at 320px it goes off screen. I measured the home page while I was at it, and even without the email, it was still 26px too wide at 320px, so the whole page could be swiped sideways. That problem existed before I touched the email.

Why 320px: WCAG 2.1 success criterion 1.4.10 Reflow says content must not need horizontal scrolling at a width of 320 CSS px. That is also what a 1280px screen looks like zoomed to 400%. Real devices at that width include the first-generation iPhone SE and some small Android phones.

## First, find out which pages

I used Playwright with the window set to 320px, opened every page in the sitemap one by one, scrolled to the bottom, and checked whether the `<html>` `scrollWidth` is larger than `clientWidth`. If it is, I list the elements whose right edge is past the viewport and which no ancestor's `overflow` clips. A horizontally scrolling carousel is naturally wider than the screen but does not widen the page, so those are excluded.

Of 156 pages, 4 overflowed:

| Page | Extra | Cause |
|---|---|---|
| Home "latest posts" | 26px | The title and the "all 44 posts →" link are on one line, and when they do not fit it does not wrap |
| `/privacy` | 8px | The long URL `static.cloudflareinsights.com` does not break |
| `/tools/area` | 43px | The dropdown options have long text, and the select widens to the longest option |
| Election map | 32px | `1fr` in the phone grid |

## Five causes, five fixes

### 1. A flex row that does not wrap

The title row is `flex justify-between`, with the title on the left and a link on the right. When the width is not enough, flex does not wrap by itself. The fix is `flex-wrap`, plus `ml-auto` on the link: when it does not fit, the link moves to the next line and stays right-aligned. At 360px and above it looks the same as before.

On the live site, removing `flex-wrap` immediately brings the overflow back to 26px.

### 2. `break-words` does not shrink min-content

The `<Code>` component on the help pages originally used `overflow-wrap: break-word` (Tailwind's `break-words`). It does let a long string break when it does not fit, but it **does not affect the min-content width**. `<Code>` sits inside a flex item in `BulletList`, and a flex item's minimum width defaults to min-content, so the full width of this URL became the floor and widened the list by 8px.

`overflow-wrap: anywhere` (`wrap-anywhere` in Tailwind v4) counts break opportunities in min-content, and switching to it fixed it. I also added a `<wbr>` after the dot in the URL so it breaks after `static.` instead of splitting into `.co` and `m`.

On the live site I removed each fix separately and measured:

| Approach | Overflow at 320px |
|---|---|
| `break-word`, no `<wbr>` | 8px |
| `break-word` plus `<wbr>` | 0 |
| `anywhere`, no `<wbr>` | 0 |

Either fix alone is enough. I kept `wrap-anywhere` because a long string added later will not necessarily remember a `<wbr>`.

### 3. A dropdown sized by its longest option

The "1 tatami equals" dropdown in `/tools/area` has long options such as "Chukyo-ma (around Nagoya, about 1.66㎡)". A `<select>`'s default width is the width of its longest option, and the outer `<label>` is a flex item, which again has content width as its floor. The fix was `min-w-0 max-w-full` on the label.

Halfway through, main merged in new styling from another session: `<select>` became `appearance: base-select` (a select you can style freely). In browsers that support it, the selected text wraps, so in Chromium removing `min-w-0` no longer overflows. But set `appearance` back to `auto` and remove `min-w-0`, and the overflow comes back at 43px. Browsers that do not support base-select yet need this fix, so I kept it.

### 4. A line break between "1.62" and "㎡"

base-select brought another problem: when the selected text wraps, it becomes "Real-estate advertising standard (1.62" on one line and "㎡)" on the next.

I first added `word-break: keep-all` (`break-keep`), and the 320px screenshot looked right. But that was luck. Later I laid out the four options at every width from 120px to 300px in 1px steps and counted the widths where "1.62" and "㎡" end up on two lines:

| Approach | Widths where they split (sum over four options) |
|---|---|
| Default | 136 |
| `keep-all` | 128 |
| `keep-all` plus U+2060 between the number and ㎡ | 0 |

Chromium's `keep-all` does not prevent the break between a number and ㎡. U+2060 (Word Joiner) is an invisible character that means "do not break the line here". I insert it in the option text with `label.replace(/(\d)㎡/g, "$1⁠㎡")`, and it breaks as "Real-estate advertising standard" and then "(1.62㎡)".

### 5. The floor of grid `1fr` is not 0

The phone layout of the election map is a single-column grid with `grid-template-columns: 1fr`. `1fr` is really `minmax(auto, 1fr)`, whose floor is the content's minimum width, so the map widened the column by 32px. Changing it to `minmax(0, 1fr)` fixed it.

(Another session later changed the map again. Today, reverting it to `1fr` on the live site no longer overflows. But `minmax(0, 1fr)` is the right way to write a single-column grid, so I kept it.)

### One more: font size that follows the column width

The large email in Contact was `clamp(1.375rem, 6.5vw, 3rem)`. At 320px that gives 22px, 16px wider than the screen. Now the outer element has `@container`, and the font size is `calc((100cqi - 1rem) / 14)`, based on the width of this column rather than the whole viewport. 14 comes from measuring that this email plus its icon is about 13.8em wide. The result is 23px at 390px, 41px at 640px, and a steady 48px at 768px and above. A longer email would need recalculating.

## Written as a test, which caught a new page on its first run

After the fixes, I turned the site-wide scan into `e2e/overflow-320.spec.ts`:

- It takes all URLs from `/sitemap.xml` and splits them into 3 parts for 3 workers in parallel. On a production build, two runs took 1.4 and 1.8 minutes.
- It scrolls each page to the bottom before measuring, so lazily loaded sections count. With "reduce motion" on, scroll animations jump to their final state.
- On failure it lists the 3 rightmost elements and their right edge positions.
- It does not use the project's usual `gotoReady`: the `data-hydrated` it waits for is set only on the home page, and on the first run all 3 parts timed out. It uses `goto` plus `networkidle`, waiting at most 15 seconds, because some pages poll constantly and never go idle.

On the very first run it caught `/tools/kaohsiung-accidents`, which another session had just put live at 16:53, with 26px extra. The error looked like this:

```text
26px extra: div.flex.items-center.gap-3 (right edge 346px "Year All 2018 2019 2020 2021");
div.flex.gap-1.5.overflow-x-auto (right edge 346px "All 2018 2019 2020 2021 20");
div.flex.items-center.gap-3 (right edge 346px "Severity Fatal+injury (A1+A2) Fatal only")
```

## The report sent me to a half-wrong fix

The year row was listed first, so I added `min-w-0` to the horizontally scrolling year row. At the same time I added `flex-wrap` to the two "severity" buttons. With both changes the test passed.

While writing this post, I removed the two fixes separately on the live site:

| Removed | Overflow at 320px |
|---|---|
| `min-w-0` on the year scroll row | 0 |
| `flex-wrap` on severity | 26px |

The real cause was only the two severity buttons not wrapping. The year row is an `overflow-x: auto` scroll container, and the flex spec already gives a scroll container an automatic minimum size of 0, so `min-w-0` did nothing, and I later removed it. All three elements had a right edge of 346px because they sit in the same grid column and were widened together by the widest row.

So this test's report can only tell you "which block got widened", not "who widened it". The first one listed is not necessarily the culprit. To be sure of the cause, remove the fixes one at a time and measure.

## Result

- On the live site, all 166 pages have 0 overflow at 320px (I also measured 360 and 390px, also 0).
- At 1440px on desktop, none of these places changed layout.
- A limitation (at the time of writing): this site's E2E has been manually triggered since 11-29 and does not run automatically on push. Later the same day it became a run in the background against the live site after every successful deploy, with an email if anything overflows, so no one has to remember to run it by hand; the story is in [the next post](/en/blog/overflow-check-after-every-deploy).

---

Author: PINGWEI LI (李秉威, Li Ping-Wei)
Original page: https://kbs0830.com/en/blog/overflow-320-every-page
