CoreCited
Technical

The viewport meta tag: what each value does, why zoom must stay on, and where charset goes

The viewport meta tag explained: what each value does, why disabling zoom fails WCAG, where meta charset must go, and Next.js defaults, with code to copy.

AlexFounder & Developer10 min read

The viewport meta tag is one line that tells a phone to lay out your page at the width of its screen, instead of at a desktop width shrunk to fit. Most sites need exactly this: <meta name="viewport" content="width=device-width, initial-scale=1">. This guide explains what each value does, why switching off zoom fails accessibility rules and mostly does not work anyway, where its neighbour meta charset must sit, and what Next.js writes for you.

The free meta tag generator writes both lines at the top of the head and warns about user-scalable=no and a maximum-scale under 2.

Key takeaways
1width=device-width matches the layout to the screen. Without it, phones may render at a desktop width and shrink the result.
2initial-scale=1 is optional by MDN's account, recommended by Lighthouse, and the Next.js default. Either way is fine.
3user-scalable=no and maximum-scale below 2 fail the W3C test rule for WCAG 1.4.4. iOS 10 and later ignore them by default anyway.
4meta charset must be utf-8 and must sit entirely within the first 1,024 bytes. Put it first in the head.
5Next.js writes both tags by default. Change them with a viewport export, not metadata.
980 px
the virtual viewport in MDN's example of a page on a 640 px screen without the tag
MDN, Sep 2026
2×
the minimum zoom WCAG requires; MDN calls 5× best practice
MDN; W3C ACT rule
1024
bytes: the charset tag must be complete within them
WHATWG, Oct 2026
0
of 14 major homepages we fetched that disable zoom
fetched 11 Oct 2026

Sources: MDN[1], the W3C ACT rule[6] and the HTML standard[3]. The site count is from the homepages listed further down.

What the viewport tag does

Definition · Viewport
MDN explains the problem the tag solves: “Some mobile devices and other narrow screens render pages in a virtual window or viewport that is wider than the screen, and then shrink the rendered result down to fit the screen size.” Its example: on a screen 640 px wide, “pages might be rendered with a virtual viewport of 980px”, then shrunk. “The viewport meta element mitigates this problem”[1].

Chrome’s Lighthouse documentation says the same in plainer words: without the tag, “mobile devices render pages at typical desktop screen widths and then scale the pages down, making them difficult to read”[8]. Google lists the tag among the meta tags it supports: it “tells the browser how to render a page on a mobile device. Presence of this tag indicates to Google that the page is mobile friendly”[7].

The copy-ready version, with charset where it belongs:

The two lines every page needs (HTML)
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- title, description and the rest follow -->
</head>

The tag does not make a layout responsive by itself. It sets the width the CSS sees; your CSS still has to fit that width. A fixed 1,200 px container will overflow a phone with or without it.

What each meta viewport value does

The content attribute is “a comma-separated list of one or more key-value pairs”[1]. These are the keys MDN documents, with their ranges:

Viewport values
Definitions and ranges from MDN, modified 23 September 2026. The advice column is ours. Toggle columns.
What it does (MDN)ValuesUse it?
widthThe (minimum) width of the layout viewport; sets the vw unit1 to 10000 px, or device-widthYes: device-width
heightThe (minimum) height of the viewport; sets the vh unit1 to 10000 px, or device-heightRarely
initial-scaleRatio between the device width and the viewport size0.0 to 10.0Optional: 1, never below 1
minimum-scaleThe minimum zoom level0.0 to 10.0Rarely; must not exceed maximum-scale
maximum-scaleThe maximum amount to zoom in; iOS 10+ ignores it by default0.0 to 10.0Leave out; never below 2
user-scalableWhether the user can zoom; iOS 10+ ignores it by defaultyes (default) or noNever set to no
interactive-widgetHow on-screen keyboards affect the viewportresizes-visual (default), resizes-content, overlays-contentFor apps with fixed footers or chat inputs
viewport-fitWhich part of a notched or rounded screen the page usesauto, contain, covercover, with safe-area padding, for full-bleed designs

You will also see shrink-to-fit=no in the wild; Microsoft and CNN sent it on 11 October 2026. It is not among the keys MDN documents today, so we leave it out of new pages.

initial-scale=1: needed or not?

Sources differ in emphasis, not in substance. MDN’s recommended setting is width=device-width alone. It calls initial-scale=1 “a common practice that’s usually unnecessary”: without it, the browser picks the starting zoom and “may zoom out when content overflows the viewport”. Add it “if overflowing content causes unwanted shrinking and you want the page to start at 100% zoom”[1]. Lighthouse recommends width=device-width, initial-scale=1, and fails a page whose initial-scale is below 1, because that can turn on double-tap-to-zoom, which “adds a 300 millisecond delay to any tap interactions”[8]. Our view: include initial-scale=1. It costs nothing and guards against a stray wide element zooming the whole page out.

Why you must not disable zoom

The most copied bad viewport is width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no. MDN’s warning is direct: disabling zoom “prevents people experiencing low vision conditions from being able to read and understand page content. Additionally, WCAG requires a minimum of 2× scaling; however, the best practice is to enable a 5× zoom”[1].

The rules behind that, from the W3C:

  • WCAG 1.4.4 Resize Text (Level AA). “Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality”[4].
  • WCAG 1.4.10 Reflow (Level AA). Content works “without requiring scrolling in two dimensions”, where “320 CSS pixels is equivalent to a starting viewport width of 1280 CSS pixels wide at 400% zoom”[5].
  • The ACT rule that tests it. “Meta viewport allows for zoom” fails a viewport whose user-scalable is no, or whose maximum-scale is below 2. Its failed examples include maximum-scale=1.0 and even maximum-scale=1.5; it maps to 1.4.4 and, in its background notes, to 1.4.10[6].

And it mostly does not work. MDN notes that for maximum-scale, minimum-scale and user-scalable, “Browser settings can ignore this rule, and iOS10+ ignores it by default”[1]. The ACT rule adds that most modern mobile browsers ignore the setting by default or offer an accessibility option to allow zooming, so the users who still get stuck are those on older browsers[6]. A tag that fails an accessibility audit and is overridden by most phones is not worth keeping.

The Next.js docs example disables zoom
The Next.js generateViewport page shows maximumScale: 1 and userScalable: false, which output maximum-scale=1, user-scalable=no. The docs present it “for completeness” and say manual configuration “is usually unnecessary as the default is sufficient”[9]. Do not paste that example as is.

Two values worth knowing: viewport-fit and interactive-widget

viewport-fit=cover lets the page fill a screen with a notch or rounded corners. MDN: “The viewport is scaled to fill the device display. It’s highly recommended to use the safe area inset variables to ensure that important content doesn’t end up outside the display”[1]. Stripe and Apple both sent it on 11 October 2026.

interactive-widget decides what happens when the on-screen keyboard opens. The default, resizes-visual, shrinks only the visible area; resizes-content resizes the viewport itself; overlays-content resizes neither[1]. Walmart’s homepage sent interactive-widget=resizes-content. It matters for layouts with a fixed footer or a chat box that should stay above the keyboard.

viewport-fit and interactive-widget, copy-ready
<!-- Full-bleed layout on phones with a notch or rounded corners -->
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">

<style>
  /* Keep content clear of the notch and the home indicator */
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
</style>

<!-- Let the on-screen keyboard shrink the layout, not just the visible area -->
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">

The meta viewport 14 big sites send

We fetched these homepages on 11 October 2026 with a desktop Chrome user agent and read the viewport tag and the position of the charset tag. None disables zoom.

Viewport and charset on 14 homepages
Fetched 11 October 2026. Charset position is the byte where the tag starts. Toggle columns.
Viewport contentCharset tag at byte
bbc.co.ukwidth=device-width, initial-scale=154
theguardian.comwidth=device-width,minimum-scale=1,initial-scale=1435
github.comwidth=device-width258
stripe.comwidth=device-width, initial-scale=1, viewport-fit=cover40
apple.comwidth=device-width, initial-scale=1, viewport-fit=cover211
walmart.comwidth=device-width, initial-scale=1.0, minimum-scale=1, interactive-widget=resizes-content40
microsoft.comwidth=device-width, initial-scale=1, shrink-to-fit=no402
edition.cnn.comwidth=device-width,initial-scale=1,shrink-to-fit=no309,677
shopify.comwidth=device-width,initial-scale=11,986
yahoo.comwidth=device-width, initial-scale=1122
en.wikipedia.orgwidth=1120627
craigslist.orgwidth=device-width,initial-scale=136
developer.mozilla.orgwidth=device-width, initial-scale=1.0172
nextjs.orgwidth=device-width, initial-scale=1423

Two rows stand out. Wikipedia’s desktop page sets a fixed width=1120: it is a desktop layout, and the tag says so honestly rather than pretending to fit a phone. And two charset tags start well past byte 1,024, which is the next section.

Meta charset: utf-8, in the first 1,024 bytes

The viewport’s neighbour has two strict rules. The HTML standard says the value, if present, must be an ASCII case-insensitive match for utf-8, and “the actual character encoding used to encode the document must be UTF-8”. And placement: “The element containing the character encoding declaration must be serialized completely within the first 1024 bytes of the document.” There may be only one, and a document must not have both a charset tag and an http-equiv encoding declaration[3]. MDN puts the same rules in one line: the tag “must be located entirely within the first 1024 bytes of the document”[2]. Google recommends “Unicode/UTF-8 where possible”[7].

The standard also says when the tag is required: if a document “does not start with a BOM, and its encoding is not explicitly given by Content-Type metadata”, the encoding must be declared with a meta element[3]. That is why the two outliers above still display correctly. CNN’s charset tag started at byte 309,677 of a 5.8 MB page, and Shopify’s at byte 1,986, but both servers sent Content-Type: text/html; charset=utf-8, so the browser knew the encoding before reading a byte of HTML.

Belt and braces
Send charset=utf-8 in the Content-Type header, and make <meta charset="utf-8"> the first element in the head. Then a cached copy, a saved file or a proxy that drops the header still decodes correctly.
Myth
maximum-scale=1 just stops annoying zoom on form fields.
What is true
It fails the W3C test rule for WCAG 1.4.4, and iOS 10 and later ignore it by default anyway.
Myth
initial-scale=1 is required.
What is true
MDN calls it usually unnecessary. It is harmless and common; a value below 1 is the one to avoid.
Myth
The viewport tag makes a site responsive.
What is true
It sets the layout width. Your CSS still has to fit that width.
Myth
Any charset tag in the head is fine.
What is true
It must be utf-8 and complete within the first 1,024 bytes, so it belongs first.

The viewport in Next.js

In the App Router you rarely write either tag. Next.js documents two default tags “that are always added even if a route doesn’t define metadata”: <meta charset="utf-8" /> and <meta name="viewport" content="width=device-width, initial-scale=1" />[10]. To change the viewport, export a viewport object, or a generateViewport function when it depends on the request. Both are “only supported in Server Components”, you cannot export both from one segment, and both were introduced in v14; a codemod moves viewport settings out of old metadata exports[9].

app/layout.tsx: extending the default viewport
// app/layout.tsx. Next.js already writes these two tags on every page:
//   <meta charset="utf-8" />
//   <meta name="viewport" content="width=device-width, initial-scale=1" />
// Export a viewport only to change or extend them.
import type { Viewport } from "next";

export const viewport: Viewport = {
  width: "device-width",
  initialScale: 1,
  viewportFit: "cover",
  themeColor: [
    { media: "(prefers-color-scheme: light)", color: "#ffffff" },
    { media: "(prefers-color-scheme: dark)", color: "#0b0b0c" },
  ],
  // Do NOT copy maximumScale: 1 or userScalable: false from examples.
};

The Viewport type also takes colorScheme and, less commonly, interactiveWidget[9]. For how the rest of a Next.js head reaches crawlers, including metadata streamed into the body, see the Next.js SEO guide.

How to check a page

Three commands show the viewport, where the charset tag sits, and whether the server declares the encoding:

Check viewport and charset from the command line
# The viewport and charset tags a page sends, as a crawler sees them
curl -sL https://www.example.com/ | grep -ioE '<meta[^>]+(viewport|charset)[^>]*>'

# Where the charset tag starts, in bytes from the top (must end before 1024)
curl -sL --compressed https://www.example.com/ | grep -b -o -iE '<meta[^>]*charset' | head -1

# Does the server already declare the encoding?
curl -sI https://www.example.com/ | grep -i '^content-type'

In Lighthouse, the viewport check has moved into the “Optimize viewport for mobile” insight as of Lighthouse 13[8]. For the other head tags, the meta tags for SEO guide lists what Google supports and what it ignores, and the AI SEO checker runs a page through the wider set of on-page checks.

width=device-width is all most pages need. Most of what people add after it does more harm than good.
Viewport and charset, done right
0/8

Questions people ask

What is the viewport meta tag?

It is a <meta name="viewport"> tag in the page's head that tells mobile browsers how wide to lay out the page and how to scale it. Without it, many phones lay the page out at a desktop width and shrink it to fit, so text is tiny. With width=device-width, the layout matches the screen.

What should the meta viewport be?

<meta name="viewport" content="width=device-width, initial-scale=1"> suits almost every site. MDN's recommended setting is width=device-width alone and calls initial-scale=1 usually unnecessary, while Lighthouse's example and Next.js's default include it. Either is fine. Do not add user-scalable=no or a maximum-scale below 2.

Is user-scalable=no bad for accessibility?

Yes. MDN says it prevents people with low vision from reading the page, and the W3C test rule for WCAG 1.4.4 fails any viewport with user-scalable=no or a maximum-scale under 2. MDN also notes iOS 10 and later ignore it by default, so it mostly fails audits without even working.

Does the viewport meta tag affect SEO?

Google lists viewport among the meta tags it supports and says the tag's presence indicates to Google that the page is mobile friendly. We found no Google statement that the tag itself is a ranking factor.

Where should meta charset go?

First in the head. The HTML standard says the element declaring the encoding must be serialized completely within the first 1024 bytes of the document, and its value must be utf-8. Placing <meta charset="utf-8"> as the first child of <head> meets both rules on any page.

Do I need a viewport tag in Next.js?

No. Next.js adds <meta charset="utf-8"> and <meta name="viewport" content="width=device-width, initial-scale=1"> to every route by default. To change the viewport, export a viewport object or a generateViewport function from a layout or page. Since Next.js 14 the viewport has its own export, separate from metadata.

Keep reading

Sources

[1]<meta name="viewport"> — MDN Web Docs, modified 23 September 2026
[2]<meta>: the metadata element — MDN Web Docs, modified 24 April 2026
[4]Understanding Success Criterion 1.4.4: Resize Text — W3C, WCAG 2.2, updated 6 September 2026
[5]Understanding Success Criterion 1.4.10: Reflow — W3C, WCAG 2.2, updated 6 September 2026
[6]Meta viewport allows for zoom (rule b4f0c3) — W3C Accessibility Conformance Testing rules, updated 25 October 2022
[7]Meta tags and attributes that Google supports — Google Search Central, updated 10 December 2025
[8]Does not have a <meta name="viewport"> tag with width or initial-scale — Chrome for Developers (Lighthouse), updated 27 May 2024
[9]generateViewport — Next.js documentation, updated 9 June 2026
[10]generateMetadata (Default Fields) — Next.js documentation, updated 19 August 2026

Find out where you actually stand

One real question, real AI engines, and the answer they gave — including who was named in it. No account, no card.