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 heightof 250px<div id="red-box">I am a red box with a width of 75% and a heightof 50% of inside the blue box</div></div>
which produces
I am a blue box with a width of 250px and a height of 250pxI 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
Your
.levelelement should have the width85%. - 2
Your
.levelelement should have the height85%.
Preview