CSS Length Units vh and vw

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

CSS3 introduced two units for representing size.

  • vh, which stands for viewport height is relative to 1% of the viewport height
  • vw, which stands for viewport width is relative to 1% of the viewport width
3
div { 
  width: 20vw; 
  height: 20vh;
}

Above, the size for the div takes up 20% of the width and height of the viewport



Got any CSS Question?