Give #box a 20px margin on every side.
Acceptance criteria
- 1.Give #box a 20px margin on every side.
CSS Tutorial · CSS Box Model
These 10 tasks go with the CSS Margin 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: “Control space outside an element's border, use logical margins, understand vertical margin collapsing, and center constrained blocks safely.” Read the chapter.
1.Add margin on all sidesexercise · easy · 10 min
Give #box a 20px margin on every side.
Passes when: Give #box a 20px margin on every side.
2.Add margin to one sideexercise · easy · 10 min · practice plan
Give #box a 30px bottom margin only.
Passes when: Give #box a 30px bottom margin only.
3.Use the two-value shorthandexercise · easy · 10 min · practice plan
Give #box 10px vertical and 40px horizontal margin.
Passes when: Give #box 10px vertical and 40px horizontal margin.
4.Use rem unitsexercise · easy · 10 min · practice plan
Give #box a 1rem margin on all sides (16px).
Passes when: Give #box a 1rem margin on all sides (16px).
5.Pull an element upexercise · medium · 10 min · practice plan
Give #other a -10px top margin to overlap the box above.
Passes when: Give #other a -10px top margin to overlap the box above.
6.Fix padding used instead of marginbug fix · easy · 8 min
Space outside the element is margin, not padding.
Passes when: Space outside the element is margin, not padding.
7.Fix the missing unitbug fix · easy · 8 min · practice plan
A bare number is invalid for margin, so nothing applies.
Passes when: A bare number is invalid for margin, so nothing applies.
8.Fix the wrong sidebug fix · easy · 8 min · practice plan
The margin was applied to the top instead of the bottom.
Passes when: The margin was applied to the top instead of the bottom.
9.Fix the reversed shorthandbug fix · easy · 8 min · practice plan
The vertical and horizontal values are swapped.
Passes when: The vertical and horizontal values are swapped.
10.Fix the misspelled propertybug fix · easy · 8 min · practice plan
"margins" is not a CSS property.
Passes when: "margins" is not a CSS property.
Between them these tasks cover Margin shorthand, Per-side margins and Spacing.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.