What is a viewport in the context of the web?
Viewport is the visible area of a web page within the device's window (browser, phone, tablet). What the user actually sees without scrolling is the viewport.
Features:
- on desktop, the viewport ≈ the browser window;
- on mobile, the viewport is usually smaller than the site's full width, and the browser may scale the page;
- the viewport size directly affects responsive layout, media queries, and element behavior.
The viewport is most often controlled via a meta tag:
html
<meta name="viewport" content="width=device-width, initial-scale=1.0">It tells the browser:
- use the actual device width (
width=device-width), - not scale the page by default (
initial-scale=1.0).
Summary: viewport is the "screen window" inside which the page is displayed, and it is exactly its dimensions that are used for responsive design.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.