CSS Percentage Unit

Percentage units are relative to the parent element.

Preview

Code

<style>
.container{
width:300px;
background:#e5e7eb;
}

.box{
width:50%;
height:50px;
background:#22c55e;
}
</style>

<div class="container">
<div class="box"></div>
</div>

More CSS Units Examples (8)