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 ?
0
give a positive ratinggive a negative rating
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>

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us