Home / Fix guides / Mobile and usability

How to fix "viewport not set" on your mobile site

A missing viewport meta tag makes phones show your desktop layout shrunk to fit. The fix is usually one line of HTML in the <head> of your pages, and it takes a few minutes once you know where your theme keeps it.

When a page has no viewport meta tag, a phone assumes the page was built for a desktop screen. It loads the page at a wide virtual width (often around 980 pixels) and shrinks it to fit. Your visitors get a tiny, zoomed-out copy of your site, even if your design is fully responsive. The tag tells the phone to use its real screen width instead.

What the problem looks like

Visitors open your site on a phone and see the whole desktop layout squeezed onto a small screen. Text is tiny, buttons are hard to hit, and they have to pinch and zoom to read anything. A menu that should collapse into a mobile menu stays as a long row of links, because the browser believes the screen is wide.

The confusing part is that your responsive CSS may be perfectly fine. Without the tag, the phone never reports its true width, so the mobile styles never switch on.

Why it matters

  • Search: Google indexes and ranks the mobile version of your pages (mobile-first indexing). A page that is hard to use on a phone is a weaker page in search. Lighthouse and PageSpeed Insights both report a missing viewport tag.
  • Sales: people who cannot read a page or tap a button simply leave. For a shop or a booking page, that is lost enquiries.
  • Trust: a zoomed-out site looks neglected, even when the business behind it is not.
  • Accessibility: readable text at the default zoom level helps everyone, especially people with weaker eyesight.

How to check if your site has it

All of these are free:

  1. Use a real phone. Open your home page and a few inner pages. If it looks like a tiny desktop site, the tag is probably missing.
  2. View the page source. On a computer, right-click the page, choose View Page Source, then search (Ctrl+F or Cmd+F) for viewport. You should find one line inside the <head> section.
  3. Use Chrome DevTools. Press F12, turn on the device toolbar (Ctrl+Shift+M), and pick a phone size. Without the tag the page appears zoomed out instead of reflowing.
  4. Run PageSpeed Insights or Lighthouse. Look in the results for an audit about the viewport meta tag.
  5. Let a test find it for you. SiteMonday's week 5 mobile usability test checks for this and lists it in the ranked fix list, with an explanation of what to change.

Check more than the home page. Landing pages, blog posts and shop pages are sometimes built from different templates, and only one of them may be missing the tag.

How to fix it in general

Add this line inside the <head> of every page, ideally once in the shared header template:

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

width=device-width tells the phone to use its real screen width. initial-scale=1 stops it from zooming the page in or out at the start.

A few things to get right:

  • Put it in the <head>, not the <body>, and only once per page. Remove duplicates.
  • Do not add user-scalable=no or maximum-scale=1. They stop visitors from pinching to zoom, which hurts accessibility.
  • Avoid fixed widths such as width=1024. That forces the same zoomed-out result you are trying to fix.
  • Check the spelling. A typo such as device-widht is silently ignored.

After the tag goes in, you may see new problems that were hidden before, such as content wider than the screen. See horizontal scrolling on mobile if that happens.

Where to add it on common platforms

Menu names and file locations depend on your theme and version, so treat these as the usual places to look.

  • WordPress: most modern themes already include it. If yours does not, it normally belongs in the theme's header.php inside <head>. Use a child theme so updates do not overwrite your change. See the WordPress guide.
  • Shopify: in the admin, go to Online Store, Themes, Edit code, then open layout/theme.liquid and look inside <head>. See the Shopify guide.
  • Drupal: Drupal core normally adds it automatically. If it is missing, check whether a custom theme removes it or overrides the html.html.twig template, depending on your theme.
  • Joomla: look in your template's index.php inside <head>. Current default templates normally include it.
  • Magento: the tag is usually set in the theme's default_head_blocks.xml layout file.
  • Next.js: in the App Router, export a viewport object from your root layout. In the Pages Router, add the tag with next/head.
  • React (Vite or Create React App): edit index.html (in the project root for Vite, in public/ for Create React App).
  • Website builders such as Wix or Squarespace: these add it automatically. If a page still looks zoomed out, contact their support rather than editing code.

If you are not comfortable editing theme files, ask your developer. It is a very small change, and take a backup first.

How to confirm the fix worked

  1. Clear your site cache, including any caching plugin and CDN, so the old pages are not served.
  2. Reload the page, view the source and find the viewport line inside <head>.
  3. Open the page on a real phone. The layout should fit the screen and text should be readable without zooming.
  4. Run Lighthouse or PageSpeed Insights again and confirm the viewport audit passes.
  5. Repeat on your main templates: home page, a content page, a product or service page, and any checkout or contact form.

Also tap through your menu and any popups. If those look broken, see hamburger menu not working or tap targets too small.

How to stop it coming back

  • Keep the tag in one shared header template, not pasted into individual pages.
  • Use a child theme or a version-controlled template so theme updates do not remove it.
  • Recheck on a phone after every redesign, theme change, migration or new landing page tool.
  • Test new templates on a phone before they go live, not only on a desktop browser.
  • Ask your developer to add a mobile check to their routine before publishing changes.

Step by step for your platform

Questions

What does the viewport meta tag do?

It tells a mobile browser to match the page width to the screen width instead of pretending the screen is a desktop. Without it, responsive layouts do not switch to their mobile styles.

Can I fix this without a developer?

Often yes. On many platforms it is one line pasted into the theme's header template, or a setting your theme already handles. If you are unsure, take a backup first or ask your developer.

Will adding the tag change how my site looks on desktop?

No. Desktop browsers ignore it. It only affects phones and tablets.

Is user-scalable=no a good idea?

No. It stops visitors from pinching to zoom, which is an accessibility problem. Use `width=device-width, initial-scale=1` and leave zooming enabled.

I added the tag but my site still looks zoomed out. Why?

Usually a cache is serving the old page, or the tag is in the wrong place, duplicated, or misspelled. Clear all caches, view the page source and check that one correct line sits inside `<head>`.

Does this affect my Google rankings?

It can. Google ranks based on the mobile version of your pages, so a page that is hard to use on a phone is at a disadvantage. Fixing it removes a known usability problem.

Related problems