Website looks broken on mobile

PlatformAny website Doing it yourself30 to 90 minutes Checked

The short answer

Usually one element is wider than the screen, which pushes the whole page sideways, or the page lacks the viewport tag that tells phones to use their real width. Find the widest element with one line in the browser console, then give images, tables and embeds a flexible width.

Is this your problem?

  • The page scrolls sideways
  • Text is tiny and you have to zoom
  • Elements overlap or run off the edge
  • The menu will not open
  • Buttons are too small or too close to tap

What usually causes it

1
No viewport tag

How to tell: The whole page looks like a shrunken desktop page.

2
Something with a fixed width

How to tell: A table, image, video or embed is wider than the phone.

3
Desktop-only settings in the page builder

How to tell: It looks right in the desktop view of the builder and wrong in the mobile view.

4
A theme that was never built for phones

How to tell: The theme is many years old.

Before you touch anything

  • Test on a real phone as well as the browser device view.

How to fix it, step by step

  1. 1

    Check the viewport tag

    View the page source and look for this line in the head. If it is missing, the theme needs it.

    <meta name="viewport" content="width=device-width, initial-scale=1">
  2. 2

    Find what is too wide

    On the page, open the browser console with a phone-sized window and run this. It lists every element that runs past the screen edge.

    [...document.querySelectorAll("*")].filter(e => e.getBoundingClientRect().right > document.documentElement.clientWidth).forEach(e => console.log(e));
  3. 3

    Make media flexible

    Add this to the theme custom CSS. It stops images and embeds from being wider than their space, and lets wide tables scroll inside their own box.

    img, video, iframe { max-width: 100%; height: auto; }
    iframe { aspect-ratio: 16 / 9; }
    .table-wrap { overflow-x: auto; }
  4. 4

    Fix it in the builder

    Switch the page builder to its mobile view and check widths, font sizes and hidden elements for each section.

  5. 5

    Make things easy to tap

    Buttons and links should be at least 48 pixels tall and spaced apart. Form fields need a 16 pixel font, or iPhones zoom in when tapped.

  6. 6

    Clear caches and test again

    Some caches keep a separate mobile copy of each page. Clear them all.

Stop and get help if

  • The theme has no mobile layout at all. Patching it costs more than a modern rebuild.
Fix it for me

Stop it happening again

  • Check every new page on a phone before publishing.
  • Use a theme that is still updated.

Questions people ask

Does a broken mobile layout hurt Google rankings?

Google ranks the mobile version of your site, so yes, a poor phone experience works against you.

Where did the Google mobile-friendly test go?

Google retired it. Lighthouse in Chrome DevTools and PageSpeed Insights check the same things.

Still broken? We can fix it.