0
0
CSSmarkup~10 mins

Margin in CSS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add space outside the box using margin.

CSS
div {
  margin: [1];
}
Drag options to blanks, or click blank then click option'
A10rem
Bcenter
Csolid
D10px
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'solid' which is a border style, not a margin value.
Using 'center' which is not a valid margin value.
2fill in blank
medium

Complete the code to add equal margin on all sides of the paragraph.

CSS
p {
  margin: [1];
}
Drag options to blanks, or click blank then click option'
Anone
Bauto
C5em
Dbold
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'auto' which centers block elements horizontally but does not set equal margin on all sides.
Using 'none' which removes margin but is not a valid margin value.
3fill in blank
hard

Fix the error in the margin shorthand to set top and bottom margin to 10px and left and right margin to 20px.

CSS
section {
  margin: [1];
}
Drag options to blanks, or click blank then click option'
A20px 10px
B10px 20px
C10px 20px 10px
D20px
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the values so left and right get 10px instead of 20px.
Using three values which is invalid shorthand for margin.
4fill in blank
hard

Fill both blanks to set margin-top to 15px and margin-left to 5rem.

CSS
div {
  margin-top: [1];
  margin-left: [2];
}
Drag options to blanks, or click blank then click option'
A15px
B5rem
C10px
D2em
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up margin-top and margin-left values.
Using units inconsistently.
5fill in blank
hard

Fill all three blanks to create a margin shorthand that sets top margin to 10px, right margin to 20px, and bottom margin to 30px.

CSS
article {
  margin: [1] [2] [3];
}
Drag options to blanks, or click blank then click option'
A10px
B20px
C30px
D40px
Attempts:
3 left
💡 Hint
Common Mistakes
Using four values instead of three for this case.
Mixing the order of values.