Viewport

Viewport

Glossary

The viewport is the visible display area of a website on a screen or device. In web development and responsive web design, it forms the basis for how layout and content are adapted to different screen sizes, without a correctly configured viewport, responsive design doesn’t work reliably.

The viewport meta tag

For mobile browsers to display a page at the actual device width instead of a shrunken desktop view, every responsive website needs this tag in the <head>:

<meta name="viewport" content="width=device-width, initial-scale=1">
  • width=device-width: the layout viewport orients itself on the actual device width instead of a fixed desktop width.
  • initial-scale=1: the page is displayed without additional zoom on first load.

Without this tag, mobile browsers load the page at a desktop width by default (usually 980px) and then scale it down – text and elements look tiny and hard to read as a result.

Layout viewport vs. visual viewport

  • Layout viewport: the entire available display area on which the page is rendered – can be larger than the actually visible area.
  • Visual viewport: the section of it actually visible without scrolling or zooming. When zooming in, the layout viewport stays unchanged while the visual viewport shrinks.

Responsive design primarily takes the visual viewport into account to ensure content is appropriately scaled and arranged on every screen size.

Dynamic viewport units: dvh, svh, lvh

A long-underestimated problem: classic CSS units like vh (viewport height) don’t account for mobile browsers showing and hiding their address bar while scrolling – the actually visible height changes continuously as a result, which led to jumping layouts. Modern CSS units solve this in a targeted way:

UnitMeaning
svhSmall viewport height – the smallest possible height (address bar shown)
lvhLarge viewport height – the largest possible height (address bar hidden)
dvhDynamic viewport height – adapts live to the current height

For elements meant to reliably fill the full screen height (hero sections, say), dvh units are today the more robust choice over classic vh.

Viewport and mobile-first design

A correctly configured viewport is the technical prerequisite for mobile-first design – the approach of developing layouts for small screens first and then extending them step by step for larger ones. Since Google has primarily evaluated a page’s mobile presentation for indexing for years, a faultily configured viewport directly harms the search engine ranking.

Conclusion

The viewport is one of the most inconspicuous yet technically most important details of responsive web design, without correct configuration, the mobile presentation fails no matter how well thought-out the rest of the layout is. We account for viewport and responsive requirements in every project from the start. More as part of our website development or in an informal chat, with no strings attached.

Häufige Fragen

What exactly does the <meta name="viewport"> tag do?
It tells the browser how wide the page should be displayed and with which zoom factor it’s initially loaded. Without this tag, mobile browsers would load a page at desktop width by default and then display it shrunk, with the tag, the actual device width is used as the basis, which is what makes responsive design take effect at all.
What's the difference between the layout viewport and the visual viewport?
The layout viewport is the entire area on which the web page is rendered and can be larger than the actually visible area. The visual viewport is the section of it actually visible without scrolling or zooming. When zooming in, for instance, the layout viewport stays the same size while the visual viewport shrinks.
Why does a website without a viewport meta tag look shrunken on the phone?
Because without this tag, mobile browsers assume a desktop page width by default (usually 980px) and then automatically scale the page down to the actual screen width – the text is rendered tiny as a result. The viewport meta tag prevents this behaviour by prescribing the real device width as the basis.
What are dynamic viewport units (dvh, svh, lvh) and what are they needed for?
Classic viewport units like vh don’t account for mobile browsers showing and hiding their address bar while scrolling, which changes the actually visible height continuously. The dynamic units svh (smallest possible height), lvh (largest possible height) and dvh (the current, live-adapting height) solve exactly this problem and prevent jumping layouts on mobile devices.
Is the viewport the same as the screen resolution?
No. The screen resolution is a fixed physical property of the device, measured in actual pixels. The viewport, in contrast, is a logical CSS concept influenced by the display’s pixel density and the viewport meta tag – a device with a high-resolution display can still have a comparatively small logical viewport.
How does the viewport affect SEO?
Directly: Google has used mobile-first indexing for years, meaning it primarily evaluates a page’s mobile presentation. A missing or misconfigured viewport meta tag leads to poor mobile display and thus has an immediate negative effect on ranking.
← Back to glossary
HOMEGLOSSARYVIEWPORT