Meaning of VH and VW in CSS - difference between VH, VW, %, PX
What is the difference between VH, VW, % and PX in CSS ? What does VH and VW do ?
Hi,
All of them VH, VW, % and PX are units for expressing a length in CSS. Both VH (viewport height) and VW (viewport width) are relative length units.
1 viewport unit is relative to 1% of the width or height of the viewport.
For example, when the height is set to 100vh, it is equal to 100% of the viewport height:
<style>
body {
padding: 0px;
margin: 0px;
}
.content {
height: 100vh;
width: 100%;
background-color: aqua;
}
</style>
<body>
<div class='content'>Text</div>
</body>
1 answer