/ โ† Meta Tag Fixes / Viewport Tag
In this guide
  1. Why phones need to be told
  2. Viewport values that cause problems
  3. Diagnosing viewport problems
  4. The fix, step by step
  5. Content that is still wider than the screen
  6. Where the tag lives on common platforms
  7. Stopping it coming back
  8. Questions and answers

Why phones need to be told

When smartphones arrived, almost every website was built for a desktop screen. To avoid breaking them, mobile browsers adopted a compromise: unless a page says otherwise, lay it out on a virtual canvas roughly as wide as a desktop window, typically around 980 CSS pixels, and scale it down to fit the phone. That default is still in place today. It is the reason an old page appears as a tiny, complete desktop layout on a phone.

The viewport meta tag switches that compromise off. It tells the browser to make the layout width equal to the width of the device and to start at normal zoom. Only then do the media queries in a responsive stylesheet fire at the right sizes. This is the key point: a responsive stylesheet without a viewport tag does not behave responsively on phones, because the browser reports a desktop-sized width to the CSS.

<meta name="viewport" content="width=device-width, initial-scale=1">
PartWhat it does
width=device-widthSets the layout width to the width of the screen in CSS pixels, so a phone reports something like 390 or 412 rather than 980
initial-scale=1Starts the page at 100% zoom, and on some browsers keeps the layout stable when the phone is turned sideways

Include both. Older advice suggested adding shrink-to-fit=no, which dealt with a behaviour in a Safari version from years ago; current browsers do not need it.

Why it matters for search

Google indexes and ranks pages using the version a smartphone crawler sees, so the phone experience is the one that counts. Google retired its standalone Mobile-Friendly Test and the Mobile Usability report in Search Console at the end of 2023, so those tools can no longer confirm the problem for you. Lighthouse and the Meta Tag Analyzer still check for the tag.

Viewport values that cause problems

A viewport tag that is present but wrong can be worse than one that is missing, because it looks correct at a glance. These are the settings found most often in audits:

SettingEffectWhat to do
user-scalable=noTries to stop visitors pinching to zoomRemove it. It fails the WCAG requirement to allow text to be resized
maximum-scale=1Caps zoom at 100%, which also blocks zoomingRemove it, or set it no lower than 5 if something insists on a value
width=1024 or another fixed numberForces a desktop layout width on every phoneReplace with width=device-width
initial-scale=0.5 or similarStarts the page zoomed outUse initial-scale=1 and fix the layout instead
Semicolons between valuesSome browsers tolerate them, others log a warning and may ignore partsSeparate values with commas
Two viewport tagsWhich one applies depends on the browserKeep one, in the layout that owns the head
Tag added by JavaScriptThe first layout happens before the script runsPut it in the server-rendered HTML, near the top of the head

Why blocking zoom is an accessibility failure

WCAG 2.2 success criterion 1.4.4, Resize Text, asks that text can be enlarged to 200% without losing content or function, and 1.4.10, Reflow, asks that content works at a width of 320 CSS pixels without scrolling in two directions. People with low vision rely on pinch zoom on phones. Automated checkers such as axe flag user-scalable=no and low maximum-scale values for this reason.

Safari on iPhone has ignored user-scalable=no by default for several years for exactly this reason, but Chrome on Android and other browsers still honour it. So a tag that blocks zoom may seem harmless when tested on an iPhone and still lock out Android users.

Diagnosing viewport problems

Three quick checks tell you almost everything.

  1. Is the tag in the HTML? Fetch the raw page and search for it. If nothing comes back, the tag is missing from the template, or a script adds it later.
    curl -s https://example.co.uk/ | grep -i 'name="viewport"'
  2. What width does the browser report? Open the page on a phone, or in the device toolbar of browser developer tools, and run window.innerWidth in the console. A value near 980 on a phone-sized screen means the viewport tag is not working.
  3. Does the page scroll sideways? Swipe left on a phone. If the page moves, something is wider than the screen, even though the viewport is correct. That is a layout problem, covered below.

Test a sample of templates, not only the home page. Old landing pages, legacy blog layouts, embedded booking forms and pages built by a separate page-builder canvas often have their own head and their own copy of the tag, or none at all.

๐Ÿ’ก Device emulation in browser developer tools is good for layout, but it does not reproduce every phone behaviour, such as the iOS zoom on form fields or the on-screen keyboard. Always finish on at least one real iPhone and one real Android phone.

The fix, step by step

Step 1

Check the viewport tag the server sends

Run one page of each template through the Meta Tag Analyzer, then fetch the same addresses with curl and search for name="viewport". Record for each template whether the tag is missing, duplicated, added by a script, or present with a problem value such as a fixed width or user-scalable=no. This tells you how many layout files need changing, which is usually far fewer than the number of affected pages.

Step 2

Add the standard tag once

Add <meta name="viewport" content="width=device-width, initial-scale=1"> to the head of the shared layout, directly after the charset declaration and before stylesheets. If a theme, plugin and page builder each print one, keep the copy in the layout that controls the head and switch the others off. Do not add a second tag to override the first, because browsers do not agree on which copy wins.

Step 3

Remove zoom restrictions

Delete user-scalable=no, user-scalable=0 and any maximum-scale below 5 from the tag. These were often added to stop layouts looking broken when zoomed, or to stop accidental zooming on web apps. Both are better solved in the layout itself. Zooming is how many people with low vision read on a phone, and blocking it fails the WCAG requirement to allow text to be resized.

Step 4

Stop phones zooming into form fields

Safari on iPhone zooms the page when someone taps into an input, select or textarea whose text is smaller than 16 CSS pixels, and does not zoom back out. That is usually why developers added maximum-scale=1. Fix the cause instead by giving form controls a font size of at least 16px, or 1rem with a 16 pixel root, which stops the zoom without taking zoom away from anyone.

Step 5

Handle notches and on-screen keyboards

Only if your design fills the whole screen edge to edge, add viewport-fit=cover to the tag and pad fixed headers, footers and buttons with env(safe-area-inset-top) and the matching bottom, left and right values, so nothing sits under a notch or home bar. If a fixed footer is hidden by the on-screen keyboard, test the interactive-widget value in browsers that support it, rather than removing zoom.

Step 6

Find elements wider than the screen

With the device toolbar set to a narrow width such as 320 pixels, run a console snippet that lists elements whose right edge is past the screen width, then fix each one. The usual culprits are images without max-width: 100%, tables and code blocks with no scrolling wrapper, fixed pixel widths, long unbroken web addresses, embedded maps and widths set to 100vw, which includes the scrollbar.

Step 7

Test on real widths and rerun the analyzer

Purge page and CDN caches, then load each template on a real phone in portrait and landscape, pinch to zoom, tap into a form field and swipe sideways to check nothing moves. Run Lighthouse for its viewport audit, then run the Meta Tag Analyzer again on the same sample of pages to confirm a single, correct viewport tag now appears on every template.

Content that is still wider than the screen

A correct viewport tag makes the layout width match the phone, but it does not shrink anything that has been given a fixed width. Those elements poke out past the right edge and the whole page scrolls sideways. This snippet, pasted into the console with a phone-sized window, outlines and lists the offenders:

const w = document.documentElement.clientWidth;
document.querySelectorAll('body *').forEach(el => {
  if (el.getBoundingClientRect().right > w + 1) {
    el.style.outline = '2px solid red';
    console.log(el);
  }
});

Common fixes, in the order they usually come up:

โš ๏ธ Do not hide the overflow with overflow-x: hidden on the body as a first resort. It cuts off content rather than fixing it, can break sticky positioning, and hides the problem from the next person who looks.

Where the tag lives on common platforms

PlatformWhere to lookNotes
WordPress classic themesheader.php, inside the headMost maintained themes include it. Very old themes may not; add it in a child theme
WordPress block themesPrinted by WordPress coreIf you see two, a plugin or custom snippet is adding a second one
Shopifylayout/theme.liquidAlso check password.liquid and any alternate layouts
Next.js App RouterAdded automaticallyCustomise it with the viewport export in a layout, not with a hand-written meta tag
Static sites and generatorsThe base layout fileHand-built sites often have one copy per page; search the whole project
Email templatesThe head of the email HTMLSome email clients respect it; it does no harm there

If your site uses a separate mobile address such as m.example.co.uk, the mobile pages need the tag as well. Separate mobile sites are harder to keep consistent, and a single responsive site with one viewport tag avoids a whole class of problems.

Stopping it coming back

Once phones lay the page out correctly, layout stability and speed on mobile are the next things to look at; the mobile Core Web Vitals guide covers those. The Meta Analyzer Guide explains the other head checks.

Questions and answers

1. What is the correct viewport meta tag?

For almost every website it is a single line in the head: meta name viewport with the content width=device-width, initial-scale=1. The first part makes the layout as wide as the screen and the second starts the page at normal zoom. Place it once, near the top of the head after the charset declaration. Adding more values is rarely needed. The main exception is viewport-fit=cover, for designs that deliberately fill the screen around a phone's notch or rounded corners.

2. Why does my responsive site still look tiny on phones?

Because the viewport tag is missing, duplicated with a bad value, or added by a script after the first layout. Without a working tag, mobile browsers lay the page out at a desktop-like width of around 980 CSS pixels and shrink it, so your media queries for small screens never apply. Check the raw HTML for the tag, and run window.innerWidth in the console on a phone. A number close to 980 confirms the viewport is not being applied.

3. Is user-scalable=no bad for SEO?

It is primarily an accessibility problem rather than a ranking one. Blocking pinch zoom stops people with low vision from enlarging text, which fails the WCAG success criterion on resizing text, and accessibility checkers flag it. Safari on iPhone ignores the setting by default now, but other browsers still apply it. There is no benefit that outweighs the harm, so remove user-scalable=no and any low maximum-scale value, and solve the underlying layout issue instead.

4. How do I stop iPhone zooming in when someone taps a form field?

Safari on iPhone zooms in when a form control's text is smaller than 16 CSS pixels, so the reader can see what they are typing. The reliable fix is to set the font size of inputs, selects and textareas to at least 16 pixels. Many sites instead add maximum-scale=1 to the viewport tag, which does stop the zoom but also stops people zooming deliberately, and it fails accessibility checks. Changing the font size fixes the cause without that side effect.

5. Does Google still check mobile-friendliness?

Google indexes pages using its smartphone crawler, so the mobile version of a page is the one it evaluates. It retired the standalone Mobile-Friendly Test and the Mobile Usability report in Search Console at the end of 2023, so those are no longer available as checks. Lighthouse, which is built into Chrome's developer tools and PageSpeed Insights, still tests for a viewport tag, and the Meta Tag Analyzer reports whether the tag is present and correctly configured.

6. My viewport tag is correct but the page scrolls sideways. Why?

The viewport tag only sets the width of the layout. If an element inside the page has been given a fixed width wider than the screen, such as a large image, a data table, a long unbroken link or an embedded widget, it will push past the edge and make the page scroll horizontally. Use the console snippet in this guide at a narrow width to outline those elements, then give each one a maximum width or a scrolling wrapper.

7. Do I need viewport-fit=cover?

Only if your design is meant to run edge to edge on phones with notches or rounded corners, for example a full-bleed hero or a fixed bottom bar. Without it, browsers keep content inside the safe area and fill the edges with the page background, which is fine for most sites. If you do add it, you must also pad fixed elements using the env safe-area-inset values, or buttons and menus can end up hidden under the notch or the home indicator.

Check your viewport tag with the rest of the head

The Meta Tag Analyzer reads the head of your page and checks the title, description, canonical, robots directives, viewport configuration, Open Graph and X card tags, then lists each finding with the guide that fixes it.

Open Meta Tag Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All Meta Tag Fixes  ·  Fixing Mobile Core Web Vitals  ·  Fixing Layout Shift on Responsive Pages  ·  Meta Analyzer Guide  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.