Skip to the content
Start free

Viewport meta tag

The viewport meta tag is a line of HTML in a page’s head that tells mobile browsers how wide to lay out the page and how far to zoom it at first. Its usual value is width=device-width, initial-scale=1. Without it, most phones draw the page as if on a desktop screen and shrink it, so text is tiny.

What is the viewport meta tag? #

The viewport is the visible area of a page in the browser window. On a laptop that is easy: the window is wide. On a phone the screen is narrow, and early mobile browsers solved this by pretending to be a desktop. web.dev’s responsive design basics says mobile browsers without the tag render the page at a desktop width, usually about 980px, then scale it down to fit. The viewport meta tag switches that off and asks the browser to use the real screen width instead. It is one of the oldest meta tags still in daily use, and it sits in the same <head> as your title tag and meta description.

What does each part mean? #

The content value is a list of key and value pairs split by commas. MDN’s viewport reference lists them:

Key Values What it does
width 1 to 10000, or device-width Sets the layout width in CSS pixels. device-width means the screen’s own width.
height 1 to 10000, or device-height Sets the layout height. Rarely needed.
initial-scale 0.0 to 10.0 The zoom level when the page first loads.
minimum-scale, maximum-scale 0.0 to 10.0 Limits on zoom. iOS 10 and later ignores them by default.
user-scalable yes (default) or no Whether people may zoom. Also ignored by iOS 10 and later by default.
interactive-widget resizes-visual, resizes-content, overlays-content How an on-screen keyboard changes the viewport.
viewport-fit auto, contain, cover How the page fills screens with notches or rounded corners.

MDN notes that width=device-width alone is often enough, and that initial-scale=1 is a common addition when you want the page to start at 100% zoom. web.dev explains why the pair is popular: some browsers keep the page width fixed when a phone turns sideways and zoom instead of reflowing, and initial-scale=1 sets a 1:1 link between CSS pixels and device pixels so the page uses the full width.

Google crawls and ranks the phone version of your site. Its mobile-first indexing guide says the phone version of your pages, fetched by Google’s smartphone crawler, is what gets indexed and ranked. It also recommends responsive web design as the easiest pattern to build and maintain. Responsive layouts depend on the viewport tag: without it, your CSS media queries see a 980px wide screen and never switch to the phone layout. See mobile-first indexing and mobile SEO.

The tag is not a ranking factor in itself. Google’s page experience guide asks whether content displays well on mobile and says Core Web Vitals are used by its ranking systems. A missing tag hurts both: a zoomed-out page is hard to use, and layout surprises can worsen cumulative layout shift.

Why does it matter for AI answers? #

AI crawlers read HTML, not pixels, so the tag does not change what text a large language model can read. It matters in two other ways. People who follow a link from an AI answer usually arrive on a phone, so a page that loads zoomed out wastes that visit. And AI browsers and AI agents that drive a real browser to fill in forms or buy work best when buttons and fields sit where a normal mobile layout puts them.

Is it OK to stop people zooming? #

No. MDN warns that user-scalable=no stops people with low vision from reading the page, and that a tight maximum-scale has the same effect. It says WCAG requires at least 2x scaling and that best practice is to support 5x. The W3C’s Resize Text criterion (1.4.4, level AA) asks that text can be resized up to 200 percent without loss of content or function. web.dev also advises against minimum-scale, maximum-scale and user-scalable. See web accessibility.

How does it work in practice? #

Put the tag once, near the top of the <head>:

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1" name="viewport">
  <title>Blue enamel kettle, 1.7 litre</title>
</head>

Then write CSS that adapts, such as a media query that stacks columns below a set width, and use srcset so phones get smaller images. Most themes on a content management system already print the tag. Check before you add a second one.

Common mistakes #

  • No tag at all. Common on old templates and hand-built landing pages. The page shows zoomed out on phones.
  • Two tags. A theme prints one and a plugin adds another with different values. Keep exactly one, so you know which values apply.
  • A fixed width. width=1024 forces a desktop layout on every phone.
  • Zoom locked. user-scalable=no or maximum-scale=1 fails people who need to zoom.
  • initial-scale below 1. Chrome’s Lighthouse viewport audit fails the page if initial-scale is under 1, because it can bring back double-tap zoom and a tap delay of about 300 milliseconds.
  • Tag added by script. Put it in the HTML the server sends, not in code that runs later. See JavaScript SEO.

A worked example #

A shop owner finds that phone visitors leave fast. The page source shows <meta name="viewport" content="width=1024, user-scalable=no"> from an old theme. On a phone 390 CSS pixels wide, the page is drawn at 1024 and shrunk to about 38%, and the visitor cannot zoom in. Changing it to width=device-width, initial-scale=1 lets the CSS switch to the phone layout, text shows at full size and zoom works again.

How to check it #

  1. Run the address through our Meta Tag Checker to see every meta tag the page sends, including a missing or doubled viewport.
  2. Run our SEO Checker or a wider SEO audit for mobile basics across the page.
  3. Run Lighthouse in Chrome. In Lighthouse 13 the viewport check sits in the “Optimize viewport for mobile” insight. Our Google Lighthouse page explains the report.
  4. Check speed on mobile with our Page Speed Checker (coming soon) and Core Web Vitals Checker (coming soon), or with Google PageSpeed Insights.
  5. If the page builds its head with JavaScript, test what the server really sends with our JavaScript SEO Checker.
  6. In URSY Pro, the Site audit (Pro) checks every page, and Real user speed (Pro) shows how phones really load them.

Questions #

Do I need initial-scale=1? #

MDN says it is usually not needed, but it is harmless and widely used. Lighthouse suggests the pair together.

What if my page has no head section I can edit? #

Most site builders and themes print the tag for you. Check the page source; if it is missing, ask your theme or plugin settings for a mobile or responsive option.

Can I put it in CSS instead? #

No. Keep the meta tag in the HTML head.

Sources #

Updated 24 November 2026 by URSY.

Cite this page: Viewport meta tag. URSY. Updated 24 November 2026. https://ursy.com/wiki/viewport-meta-tag/ · Section links

Tools for this

All 871 wiki entries, A to Z →