The vw and vh units

These units allow you to specify sizes in terms of percentages of the viewport width and viewport height.

The allowed units are:

  1. vw: hundredths of the viewport width.
  2. vh: hundredths of the viewport height.
  3. vm: hundredths of whichever is smaller, the viewport width or height.


Here are some examples. 50vw means 50% of the viewport width.

Don’t forget to resize your browser window to see the boxes resize automatically.

Test of width: 50vw.
Test of height: 25vh.
Test of width: 25vm.