liveBook · Manning

Viewport width unit

Also called vw, viewport unit

The CSS vw unit is a viewport-relative length equal to one percent of the viewport width.

How 3 Manning books explain it

Math for Web Design

The vw unit is a CSS viewport unit equal to one hundredth of the viewport's width.

How it is used
Sizes layouts and typography against viewport width rather than a parent’s width.
How deep it goes
Defines viewport-to-pixel conversion and derives a linear `vw` factor for bounded font scaling.
Examples
Calculates a `10vw` heading at 1,200px and bounds fluid font size with `clamp(1rem, 0.5rem + 2vw, 2rem)`.
What you can do after
Apply it via CSS to size elements against viewport width and keep fluid headings within chosen limits.

Read how Math for Web Design explains viewport width unit →

CSS in Depth, Second Edition

The CSS vw unit represents one percent of the viewport width.

How it is used
Uses viewport-relative lengths to size elements against the visible browser frame and to scale typography with viewport width.
How deep it goes
Defines vw mathematically, works through sizing and typography examples, and addresses scrollbar and mobile-viewport caveats without detailing browser internals.
Examples
Shows a 90vmin square across screen orientations and font sizes that respond continuously to viewport width.
What you can do after
Evaluate/understand when viewport-width sizing fits a layout and when scrollbars or unbounded font scaling make it troublesome.

Read how CSS in Depth, Second Edition explains viewport width unit →

Web Design Playground, Second Edition

The vw unit is a CSS viewport-relative length unit equal to one percent of the viewport width.

How it is used
Uses vw for horizontal measurements that should scale with the browser viewport rather than a parent element.
How deep it goes
Explains viewport-relative sizing, numeric conversion, and percentage contrast without developing a complete vw implementation.
Examples
Uses a 1,600-pixel viewport calculation and contrasts a child sized at 75% of its parent with viewport-relative sizing.
What you can do after
Apply vw to horizontal measurements that need to scale with viewport width.

Read how Web Design Playground, Second Edition explains viewport width unit →

Also covered in

What to know first

Related concepts

Questions about viewport width unit

What is viewport width unit?

The CSS vw unit is a viewport-relative length equal to one percent of the viewport width.

Which Manning books explain viewport width unit?

Math for Web Design, CSS in Depth, Second Edition and Web Design Playground, Second Edition.

What should I know before learning viewport width unit?

Manning books that teach viewport width unit usually introduce viewport, proportion, pixel and em first.

What kinds of viewport width unit are there?

Kinds of viewport width unit include dynamic viewport unit, large viewport unit, small viewport unit, vmax and vmin/vmax unit.

What is viewport width unit also called?

Viewport width unit is also called vw or viewport unit.

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.