Creative agency glossaryWeb, UX/UI, and Design

Viewport

The viewport is the visible area of a web page on a screen, the part of the page a visitor can see at any moment without scrolling.

What is a viewport?

On a desktop, the viewport is the browser window minus its toolbars; resize the window and the viewport changes. On a phone, it is the screen, less the browser's address bar and controls, which grow and shrink as the visitor scrolls. Everything a responsive layout does is a reaction to the viewport: its width decides which layout applies, its height decides what sits above the fold, and CSS units such as vw and vh are measured as fractions of it.

Phones complicated the idea. When the iPhone launched in 2007, most sites were built for desktops, so mobile browsers pretended to be about 980 pixels wide and shrank the page to fit. The viewport meta tag was introduced to switch that off. A single line in the page's head, setting the width to the device width, tells the phone to show the page at its real size, and without it no responsive design can work properly on mobile.

Why it matters

Why a viewport matters

Design happens in the viewport. It is the frame through which visitors see everything, and it varies more than most teams plan for: from a small phone held upright to an ultrawide monitor, with tablets, laptops and folding phones in between. A layout that ignores that range will look right on the designer's screen and wrong on most others. A missing viewport tag is still one of the most common reasons a site looks tiny and unusable on phones, and misused viewport units are behind the hero sections that jump or get cut off when a phone's address bar moves.

In practice

How a viewport works in practice

  1. 01

    Every page we build starts with the standard viewport tag, width set to the device width and initial scale set to one, and never with settings that disable zooming, which takes control away from people who need to enlarge text. Layouts respond to the viewport's width through media queries, while component-level changes increasingly respond to the space each element is given, through container queries.

  2. 02

    Height needs more care. On phones the classic vh unit is measured against the largest possible viewport, so a section set to full height can hide its bottom edge behind the toolbar. The newer units fix this: svh for the smallest viewport, lvh for the largest and dvh for the one that changes as toolbars move. We use them for full-screen sections, test on real phones in both orientations and watch how the page behaves as the address bar appears and disappears.

Watch out

What people get wrong about viewports

Designing for one viewport, usually the designer's laptop, and treating every other size as an adjustment. Second, disabling zoom in the viewport tag to stop layouts shifting, which fails accessibility guidelines and frustrates anyone with low vision. Third, building full-height sections on vh and finding the button at the bottom of the hero hidden behind a phone's toolbar for half the audience. And forgetting landscape: a phone turned sideways has a viewport only a few hundred pixels tall, where a fixed header can swallow half the screen.

Questions

People also ask

What is the viewport meta tag?

A line of HTML in a page's head that tells mobile browsers how to size the page, usually setting the width to the device's width and the initial scale to one. Without it, phones display a shrunken, desktop-width version of the page.

What is the difference between the viewport and the screen size?

The screen size is the physical display. The viewport is the part of it available to the page, which excludes browser toolbars and, on desktops, depends on how large the window is. Layouts should respond to the viewport, not the screen.

What are vw and vh units?

They are CSS units equal to one percent of the viewport's width and height. They are useful for sizing elements relative to the visible area, although on phones the newer dvh and svh units are more reliable for height.

Next to it in the glossary

  1. User InterfaceA user interface (UI) is the part of a digital product that people see and interact with, including its screens, layout, controls, type, color and feedback.
  2. User Interface (UI)A user interface is the part of a website, app or product that a person actually sees and touches: the screens, buttons, type, colors and motion through which they get things done.
  3. UX ResearchUX research is the study of how people use, understand and feel about a product, through methods such as interviews, usability tests and analytics, so that design decisions rest on evidence.
  4. Web 2.0Web 2.0 is the name for the second era of the web, from the mid-2000s, when sites became platforms where users create, share and connect rather than only read.
  5. Web AccessibilityWeb accessibility is the practice of designing and building websites so that people with disabilities, including visual, hearing, motor and cognitive disabilities, can perceive, use and understand them.
  6. Web DesignWeb design is the practice of planning and creating how a website looks, how it is organized and how it works for the people who use it, from layout and typography to navigation and interaction.

Every Web, UX/UI, and Design term →

In the work

Where it shows up

All our creations →

From the journal

Read around it

The journal →

Talking the talk is one thing

We make the work.

RIOT is a creative agency and production studio in New York. Strategy, brand, film, photography, design and the campaigns that carry them, made by one team. A few lines is enough to start: we read every brief the same day.

    Footage