Recall & Review
beginner
What is the purpose of the CSS
margin property?The
margin property creates space outside an element's border. It pushes other elements away, controlling the distance between elements.Click to reveal answer
beginner
How do you set different margin sizes for top, right, bottom, and left in CSS?
Use
margin-top, margin-right, margin-bottom, and margin-left properties to set each side's margin individually.Click to reveal answer
beginner
What does
margin: 10px 20px; mean?It sets the top and bottom margins to 10 pixels, and the left and right margins to 20 pixels.
Click to reveal answer
intermediate
What happens if you set
margin: auto; on a block element with a fixed width?The element will center horizontally within its container because the left and right margins automatically adjust equally.
Click to reveal answer
intermediate
Can margin values be negative? What does that do?
Yes, margins can be negative. Negative margins pull the element closer to or even overlap with neighboring elements.
Click to reveal answer
Which CSS property controls the space outside an element's border?
✗ Incorrect
Margin controls the space outside the border, while padding controls space inside the border.
What does
margin: 5px 10px 15px 20px; set?✗ Incorrect
The order is top, right, bottom, left when four values are given.
What effect does
margin: auto; have on a block element with a fixed width?✗ Incorrect
Setting margin: auto; horizontally centers the element inside its container.
Which margin property sets the space on the left side of an element?
✗ Incorrect
The
margin-left property controls the left margin.What happens if you use a negative margin value?
✗ Incorrect
Negative margins pull the element closer to others or overlap them.
Explain how the CSS margin property affects the space around an element and how you can control each side separately.
Think about pushing elements away from each other.
You got /3 concepts.
Describe how to center a block element horizontally using margin in CSS.
Use auto margins to balance space on sides.
You got /3 concepts.