Units — px, rem, em, %, and the Viewport — Concept Check
Questions on Units — px, rem, em, %, and the Viewport. The unit you choose decides whether your layout respects a user who has increased their browser font size. rem for type and spacing, px for hairlines, and the viewport units that actually work on phones.
Questions in this quiz
8 questions on Units — px, rem, em, %, and the Viewport — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer sets the font size of an element using 'font-size: 2rem'. If the user's browser root font size is set to 20px, what will be the computed font size of the element?
- A16px
- B40px
- C32px
- D20px
2.A website uses 'width: 100vw' for a full-width section. On a desktop browser, this causes a horizontal scrollbar to appear. Why?
- A100vw includes the scrollbar width
- BViewport units are not supported on desktop
- CThe section's content is too large
- DThe section is too wide for the viewport
3.A designer uses 'padding: 1em' on a button. If the button's font size is 20px, what will the padding be?
- A20px
- B24px
- C10px
- D16px
4.A developer wants a full-height section on mobile using 'min-height: 100vh'. What issue might they encounter on iOS?
- AThe section will not be full height
- BThe section might be taller than the visible area
- CThe section will not scale with font size
- DThe section will overlap other content
5.Which unit should be used for a border that should not scale with user font settings?
- Aem
- Brem
- C%
- Dpx
6.When setting 'padding-top: 50%' on an element, what is this percentage relative to?
- AElement's width
- BParent's height
- CParent's width
- DElement's height
7.A developer uses 'font-size: clamp(1rem, 4vw, 3rem)'. What is a potential issue with using a pure 'vw' value as the preferred size?
- AIt does not scale with user font settings
- BIt can lead to inconsistent sizes
- CIt can cause layout shifts
- DIt is not supported in all browsers
8.What happens when you set 'html { font-size: 62.5% }' to make '1rem = 10px'?
- AIt halves the text size for users with custom settings
- BIt standardizes rem to 10px
- CIt simplifies calculations
- DIt improves accessibility