CSS Units — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the CSS Units lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Use pixels
easy10 minGive #box a 150px width.
- 2
Use rem
easy10 minGive #box a 2rem font size (32px).
- 3
Use em relative to the element
easy10 minSet the box font to 20px and its padding to 1em (20px).
- 4
Use a unitless line height
easy10 minGive #box a line-height of 1.5 with no unit.
- 5
Mix units deliberately
medium10 minSet a 1rem margin and a 24px padding on the box.
Find the bug(5)
- 1
Fix the missing unit
easy8 minA bare number is invalid for width.
- 2
Fix rem mistaken for pixels
easy8 min2rem is 32px, not 2px — the intent was 32px.
- 3
Fix em compounding
easy8 minThe padding should equal the element's own 20px font size.
- 4
Fix the unit on line-height
easy8 minA unitless line-height scales with the font; 1.5 was intended.
- 5
Fix the invalid unit
easy8 min"pixels" is not a CSS unit.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace