Guides › HTML / PHP sites › Speed & performance

CSS Layout Breaks on Mobile: Viewport Meta and Overflow Fixes

Missing viewport tags and fixed widths break mobile layouts.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Slow website

A layout that looks right on a computer but is wide, zoomed out or scrolls sideways on a phone usually has a missing viewport tag or an element that is too wide.

1Add the viewport tag2Test with device mode3Find the wide element4Replace fixed widths5Fix images and tables6Hide overflow carefully7Test on a real phoneFixed? Test the site. If not, get help.
The steps in order. Work down the list and stop when the problem is solved.

Step 1: Add the viewport tag

Illustration for Step 1: Add the viewport tag

In the head put <meta name="viewport" content="width=device-width, initial-scale=1">.

Step 2: Test with device mode

Illustration for Step 2: Test with device mode

Press F12 and click the phone icon to simulate a small screen.

Step 3: Find the wide element

Illustration for Step 3: Find the wide element

Look for the element that sticks out. Right-click, Inspect and read its width.

Step 4: Replace fixed widths

Illustration for Step 4: Replace fixed widths

Change widths such as width: 800px to max-width: 100%.

Step 5: Fix images and tables

Illustration for Step 5: Fix images and tables

Add img { max-width: 100%; height: auto; } and wrap wide tables in a scrolling container.

Step 6: Hide overflow carefully

Illustration for Step 6: Hide overflow carefully

overflow-x: hidden on the body hides symptoms, so use it only after fixing the cause.

Step 7: Test on a real phone

Illustration for Step 7: Test on a real phone

Check portrait and landscape.

Still stuck?

If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-22.