viewport
The visible area of a web page in the browser window or device screen.
In more detail
The vw unit is 1% of the viewport width, so 50vw is half the window's width. Floating elements must stay inside the viewport, and visual tests lock the viewport size so screenshots are comparable.
Examples
In the browser: Layout positions are often relative to the viewport, and media queries test its width. Container queries instead test the size of a component's own container.A virtualised list renders only the items that fit in its viewport: viewport height divided by row height gives the number of rows.Related terms
- fluid typography — Font sizes that grow smoothly with the width of the screen between a minimum and a maximum, instead of jumping at breakpoints.
- clamp() — The CSS function clamp(min, preferred, max), which uses the preferred value but never goes below min or above max.
- Floating UI — A JavaScript library, and the general technique, for positioning a floating element such as a tooltip next to a reference element.
- media query — A CSS rule, written @media, that applies styles only when a condition about the device or user settings is true.
- container query — A CSS rule, written with @container, that styles a component based on the size of its container instead of the whole viewport.
- layout — The rendering stage in which the browser calculates the exact position and size of every box on the page.
- prefetching — Loading a route's data in the background before the user clicks, so navigation feels instant.
- responsive images — Offering several sizes of the same image so each device downloads the smallest one that still looks sharp.
- list virtualization — Rendering only the rows of a long list that are currently visible, plus a few extra, instead of creating DOM nodes for every item.
- scroll event — The event fired when a page or element scrolls; scrolling of an element does not bubble to the document.
Taught in
- Typography & Spatial Grids: Modular Scales & Fluid Typography — Design Systems & Component Engineering
- Floating Primitives: Popovers, Tooltips & Positioning — Design Systems & Component Engineering
- Visual Regression Testing: Playwright & Snapshot Differencing — Design Systems & Component Engineering
- Layout, Reflow, Paint And GPU Compositing Layers — Frontend Architecture & Web Platform
- Container Queries: Component-Driven Responsive Design — Frontend Architecture & Web Platform
- Router Cache: In-Memory Client Prefetch Semantics — Next.js 15 & Modern App Router Architecture
- Image & Font Optimization: Zero Layout Shift Assets — Next.js 15 & Modern App Router Architecture
- Script Optimization: next/script & Lazy Third Parties — Next.js 15 & Modern App Router Architecture
- Virtualization: Rendering Infinite Datasets Efficiently — React 19 & Modern Component Architecture