CSS Width and Height — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the CSS Width and Height 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
Set a fixed width
easy10 minMake #box 200px wide.
- 2
Set a fixed height
easy10 minMake #box 120px tall.
- 3
Cap the width
easy10 minStop #box growing past 300px.
- 4
Set a minimum height
easy10 minGive #box a minimum height of 80px.
- 5
Include padding in the width
medium10 minUse border-box so padding does not widen the box beyond 200px.
Find the bug(5)
- 1
Fix the content-box overflow
easy8 minWith content-box the padding pushes the box wider than intended.
- 2
Fix the missing unit
easy8 minA bare number is not a valid width.
- 3
Fix min and max swapped
easy8 minThe maximum is smaller than the minimum, so the box collapses.
- 4
Fix the wrong property
easy8 minThe property is max-width, not width-max.
- 5
Fix the fixed height that should be a minimum
easy8 minA hard height clips content; a minimum grows with it.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace