Skip to content

Viewport

In one line

The viewport is the visible area of a web page in the browser window where content is displayed.

In simple words

The viewport is the part of the web page that is currently visible in the browser window. Everything outside the viewport is scrolled to — it exists in the document but is not currently visible.

On mobile devices, the viewport is more complex because the browser viewport and the device screen size differ. The <meta name="viewport" content="width=device-width, initial-scale=1"> tag tells the browser to set the viewport width to the device width, which is essential for responsive design on mobile.

CSS viewport units let you size elements relative to the viewport: vw (1% of viewport width), vh (1% of viewport height), vmin (smaller of vw/vh), and vmax (larger). These are useful for full-screen sections and responsive typography.

Example

html
<meta name="viewport" content="width=device-width, initial-scale=1.0">

/* CSS using viewport units */
.hero { height: 100vh; } /* Full viewport height */
h1 { font-size: 5vw; }  /* 5% of viewport width */

The viewport meta tag for responsive mobile design, and CSS viewport units for sizing relative to the viewport.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary