Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

dvw — dynamic viewport width

The dvw unit equals 1% of the dynamic viewport width. It sizes lengths against space that accounts for browser interfaces that expand and retract.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<number>dvw

dvw is a CSS length unit: 1dvw equals 1% of the dynamic viewport width. Place the number directly before the unit, as in width: 50dvw. Its reference is not the parent element or physical screen width.

svw uses the small viewport, assuming dynamic browser interfaces are expanded; lvw and vw use the large viewport, assuming they are retracted. dvw accounts for their current state. If an interface changes only the available height, a width expressed in dvw need not change.

Dynamic units can cause layout changes during scrolling. The browser need not update them smoothly throughout an interface animation. In the example, the bar occupies half the dynamic width: at 800 CSS pixels, it is 400 CSS pixels wide.

Examples

<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>dvw</title>
<style>
  html, body { margin: 0; }
  .bar {
    width: 50dvw;
    height: 32px;
    background: steelblue;
  }
</style>
<div class="bar"></div>

Result

A steelblue bar, 32 CSS px high and half the dynamic viewport width. At a dynamic viewport width of 800 CSS px, the bar is 400 CSS px wide.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources