Make #box 200px wide.
Acceptance criteria
- 1.Make #box 200px wide.
CSS Tutorial · CSS Box Model
These 10 tasks go with the CSS Width and Height chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Set physical and logical dimensions while using min/max constraints, percentages, intrinsic content, and box sizing to prevent overflow.” .
1.Set a fixed widthexercise · easy · 10 min
Make #box 200px wide.
Passes when: Make #box 200px wide.
2.Set a fixed heightexercise · easy · 10 min · practice plan
Make #box 120px tall.
Passes when: Make #box 120px tall.
3.Cap the widthexercise · easy · 10 min · practice plan
Stop #box growing past 300px.
Passes when: Stop #box growing past 300px.
4.Set a minimum heightexercise · easy · 10 min · practice plan
Give #box a minimum height of 80px.
Passes when: Give #box a minimum height of 80px.
5.Include padding in the widthexercise · medium · 10 min · practice plan
Use border-box so padding does not widen the box beyond 200px.
Passes when: Use border-box so padding does not widen the box beyond 200px.
6.Fix the content-box overflowbug fix · easy · 8 min
With content-box the padding pushes the box wider than intended.
Passes when: With content-box the padding pushes the box wider than intended.
7.Fix the missing unitbug fix · easy · 8 min · practice plan
A bare number is not a valid width.
Passes when: A bare number is not a valid width.
8.Fix min and max swappedbug fix · easy · 8 min · practice plan
The maximum is smaller than the minimum, so the box collapses.
Passes when: The maximum is smaller than the minimum, so the box collapses.
9.Fix the wrong propertybug fix · easy · 8 min · practice plan
The property is max-width, not width-max.
Passes when: The property is max-width, not width-max.
10.Fix the fixed height that should be a minimumbug fix · easy · 8 min · practice plan
A hard height clips content; a minimum grows with it.
Passes when: A hard height clips content; a minimum grows with it.
Between them these tasks cover width and height, box-sizing and min and max sizing.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.