Challenge - 5 Problems
Viewport Units Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateUnderstanding viewport width (vw) unit
If the browser window width is 1000px, what will be the computed width of a box styled with
width: 10vw;?Attempts:
2 left
💡 Hint
Remember that 1vw equals 1% of the viewport width.
✗ Incorrect
The vw unit means 1% of the viewport width. So 10vw is 10% of 1000px, which is 100px.
📝 Syntax
intermediateWhich CSS rule correctly sets height to 50% of viewport height?
Select the CSS rule that sets an element's height to half the viewport height.
Attempts:
2 left
💡 Hint
vh means viewport height, vw means viewport width.
✗ Incorrect
vh is the unit for viewport height. So height: 50vh; sets height to 50% of viewport height.
❓ rendering
advancedWhat is the visible height of the box on a 800px tall viewport?
Given this CSS, what is the visible height of the
<div> box?div {
height: 50vh;
max-height: 300px;
}CSS
<div>Box</div>
Attempts:
2 left
💡 Hint
Check which is smaller: 50vh or max-height.
✗ Incorrect
50vh of 800px is 400px, but max-height limits it to 300px, so height is 300px.
❓ selector
advancedWhich CSS selector targets elements with width less than 50vw?
Which CSS media query correctly applies styles only when viewport width is less than 50vw?
Attempts:
2 left
💡 Hint
Media queries accept viewport units like vw and vh.
✗ Incorrect
max-width: 50vw means styles apply when viewport width is less than 50% of viewport width, which is logically consistent.
❓ accessibility
expertHow to ensure text remains readable on small viewports using viewport units?
You want text size to scale with viewport width but never become smaller than 1rem for readability. Which CSS rule achieves this?
Attempts:
2 left
💡 Hint
Use CSS functions to set minimum font size.
✗ Incorrect
max(1rem, 2vw) means font size is at least 1rem, scaling up with viewport width but never smaller than 1rem.
