0
0
CSSmarkup~10 mins

Viewport units in CSS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the width of the box to 50% of the viewport width.

CSS
div {
  width: 50[1];
}
Drag options to blanks, or click blank then click option'
Aem
Bpx
Cvh
Dvw
Attempts:
3 left
💡 Hint
Common Mistakes
Using vh which relates to viewport height, not width.
Using fixed units like px which do not scale with viewport.
2fill in blank
medium

Complete the code to set the height of the header to 10% of the viewport height.

CSS
header {
  height: 10[1];
}
Drag options to blanks, or click blank then click option'
Avh
Bvw
Crem
Dpt
Attempts:
3 left
💡 Hint
Common Mistakes
Using vw which relates to width, not height.
Using fixed units like pt which do not scale with viewport.
3fill in blank
hard

Fix the error in the code to make the box height 100% of viewport height.

CSS
.box {
  height: 100[1];
}
Drag options to blanks, or click blank then click option'
Apx
Bvh
Cem
D%
Attempts:
3 left
💡 Hint
Common Mistakes
Using % which depends on parent height.
Using fixed units like px which do not scale.
4fill in blank
hard

Fill both blanks to set the font size to 5% of viewport width and margin to 2% of viewport height.

CSS
p {
  font-size: 5[1];
  margin: 2[2];
}
Drag options to blanks, or click blank then click option'
Avw
Bvh
Cem
Dpx
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up vw and vh units.
Using fixed units like px which do not scale.
5fill in blank
hard

Fill all three blanks to create a responsive square box with width and height 30% of viewport width and padding 1% of viewport height.

CSS
.square {
  width: 30[1];
  height: 30[2];
  padding: 1[3];
}
Drag options to blanks, or click blank then click option'
Avh
Bvw
Dpx
Attempts:
3 left
💡 Hint
Common Mistakes
Using vh for width or height which can distort the square.
Using fixed units like px which do not scale.