Viewport
A viewport is the visible region of a browser or graphical interface in which a document or other content is displayed.
Math for Web Design
The viewport is the visible area of a browser window in which a web page is rendered.
- How it is used
- Uses the visible browser area as a reference for responsive sizing, element measurements, and pointer positions.
- How deep it goes
- Defines the coordinate origin and units, works through sizing and DOM measurements, and distinguishes mobile toolbar-dependent viewport heights.
- Examples
- Demonstrates a full-screen hero, clamped margin, mobile overflow fix, and cursor-following tooltip.
- What you can do after
- Apply it via CSS viewport units and JavaScript DOM APIs to size layouts and position interface elements.
CSS in Depth, Second Edition
A viewport is the framed area of a browser window in which a web page is visible, excluding browser interface controls.
- How it is used
- Defines responsive lengths for viewport-filling heroes, mastheads, and orientation-resistant elements.
- How deep it goes
- Defines original and newer viewport units, explains orientation behavior and trade-offs, and notes scrollbar and keyboard caveats.
- Examples
- Uses a 90vmin square, a full-height hero image, and lvh-versus-svh masthead sizing.
- What you can do after
- Apply viewport-relative units to size responsive elements and choose large or small viewport behavior for mastheads.
Tiny CSS Projects
A browser viewport is the visible rectangular area through which a web page is rendered.
- How it is used
- Frames responsive SVG graphics inside a loading screen.
- How deep it goes
- Defines frame sizing and overflow, then distinguishes viewport dimensions from viewBox positioning and scaling.
- Examples
- Uses a scanning loader, a 100-percent-wide SVG, a 300-pixel frame, and a 710-by-300 viewBox.
- What you can do after
- Apply via SVG width and height attributes to create a responsive frame for contained graphics.
Also covered in
- Build a Website with ChatGPT
- Modern Angular
- Web Design Playground, Second Edition
- D3.js in Action, Third Edition
- Design for Developers
- Web Design Playground
- Vanilla WebIn early access (MEAP)
What to know first
- block-level elementA block-level element is an HTML element that participates in block layout, typically starting on a new line and occupying the available width of its container.
Related concepts
- fixed positioningused by · Fixed positioning is a CSS positioning mode that places an element relative to the viewport or a fixed-position containing block, keeping it stationary as document content scrolls.
- getBoundingClientRectused by · getBoundingClientRect is a DOM method that returns an element's size and position relative to the viewport.
- viewport width unitused by · The CSS vw unit is a viewport-relative length equal to one percent of the viewport width.
- media queryused by · A media query is a CSS conditional rule that applies styles when specified media types or presentation-environment features match.
- viewbox attributeconfigured by · The SVG viewBox attribute specifies the position and dimensions of an internal coordinate system that is mapped to the graphic’s viewport.
Questions about viewport
What is viewport?
A viewport is the visible region of a browser or graphical interface in which a document or other content is displayed.
Which Manning books explain viewport?
Math for Web Design, CSS in Depth, Second Edition and Tiny CSS Projects.
What should I know before learning viewport?
Manning books that teach viewport usually introduce block-level element first.
What is viewport a kind of?
Viewport is a kind of 2d coordinate system. A coordinate system that represents positions in a two-dimensional space using two perpendicular axes.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


