CSS Length Units

Percentage

We use percentages to specify lengths when we want to size on item relative to its parent element.

Code example

<style>
#blue-box {
width: 250px;
height: 250px;
background-color: blue,
color: white;
}
#red-box {
width: 75%;
height: 50%;
background-color: red,
color: black;
}
</style>
<div id="blue-box">
I am a blue box with a width of 250px and a height
of 250px
<div id="red-box">
I am a red box with a width of 75% and a height
of 50% of inside the blue box
</div>
</div>

which produces

I am a blue box with a width of 250px and a height of 250px
I am a red box with a width of 75% and a height of 50% inside the blue box

Test yourself

Description

Change the width of the .level element to

85%

and the height of the .level element to

85%

All of the rules are defined for you. You only need to modify the correct declarations.

Tests

  1. 1 Your .level element should have the width 85%.
  2. 2 Your .level element should have the height 85%.
Editor
Preview