The four parts are: content, padding, border, and margin. Content is the actual stuff inside the box. Padding is space inside the box around the content. Border is the line around the padding. Margin is the space outside the border separating boxes.
Click to reveal answer
beginner
How does padding affect the size of a box?
Padding adds space inside the box around the content, making the box bigger without changing the content size. It pushes the border outward.
Click to reveal answer
beginner
What is the difference between margin and padding?
Padding is space inside the box between content and border. Margin is space outside the box that separates it from other boxes.
Click to reveal answer
beginner
Why is understanding the box model important for web layout?
Because it helps you control spacing and size of elements on a page. Knowing how content, padding, border, and margin work lets you design neat and organized layouts.
Click to reveal answer
intermediate
What happens if you set margin to auto on a block element?
Setting margin to auto horizontally centers the block element within its container if the width is fixed.
Click to reveal answer
Which part of the box model is directly around the content?
ABackground
BPadding
CBorder
DMargin
✗ Incorrect
Padding is the space inside the box that surrounds the content.
What does the margin do in the box model?
AAdds space outside the border
BAdds space inside the content
CCreates a border line
DChanges the content size
✗ Incorrect
Margin adds space outside the border, separating the box from others.
If you want to add space between the content and the border, which property do you use?
ABorder-width
BMargin
CPadding
DWidth
✗ Incorrect
Padding adds space inside the box between content and border.
What effect does increasing the border width have on the box size?
AIt makes the box smaller
BNo effect on box size
CIt changes the content size
DIt makes the box bigger
✗ Incorrect
Increasing border width adds to the total size of the box.
How can you center a block element horizontally using margin?
ASet margin to auto
BSet padding to auto
CSet margin-left and margin-right to 0
DSet border to auto
✗ Incorrect
Setting margin-left and margin-right to auto centers the block horizontally.
Explain the CSS box model and how each part affects the size and spacing of an element.
Think about what is inside the box and what is outside.
You got /5 concepts.
Describe how you would center a block element horizontally on a webpage using the box model properties.
Focus on margin settings.
You got /4 concepts.
Practice
(1/5)
1. Which part of the box model adds space inside the element but outside the content?
easy
A. Margin
B. Content
C. Border
D. Padding
Solution
Step 1: Understand the box model layers
The box model has content in the center, then padding, border, and margin outside it.
Step 2: Identify the layer adding space inside the element
Padding adds space inside the element, between content and border.
Final Answer:
Padding -> Option D
Quick Check:
Padding = space inside element [OK]
Hint: Padding is inside space around content, margin is outside [OK]
Common Mistakes:
Confusing margin with padding
Thinking border adds inner space
Mixing content with padding
2. Which CSS property correctly sets the space outside an element's border?
easy
A. margin
B. content-spacing
C. border-width
D. padding
Solution
Step 1: Recall box model spacing properties
Margin controls the space outside the border of an element.
Step 2: Match property to outside space
Only margin sets space outside the border; padding is inside, border-width sets border thickness.
Final Answer:
margin -> Option A
Quick Check:
Margin = outside space [OK]
Hint: Margin controls outside space, padding controls inside space [OK]
Common Mistakes:
Using padding instead of margin
Confusing border-width with margin
Using non-existent property content-spacing
3. If an element has content width 100px, padding 10px, border 5px, and margin 20px, what is its total width including margin?
medium
A. 150px
B. 170px
C. 190px
D. 210px
Solution
Step 1: Calculate width including padding and border
Total width without margin = content width + 2*padding + 2*border = 100 + 20 + 10 = 130px.
Step 2: Add margin on both sides
Total width including margin = 130 + 2*20 = 130 + 40 = 170px.
Step 3: Recalculate carefully
Correction: Padding 10px each side = 20px total, border 5px each side = 10px total, margin 20px each side = 40px total. So total width = 100 + 20 + 10 + 40 = 170px.
Hint: Default box-sizing excludes padding from width [OK]
Common Mistakes:
Assuming width includes padding
Confusing margin with padding
Ignoring box-sizing property
5. You want two boxes side by side inside a 500px container. Each box has width: 220px;, padding: 10px;, border: 5px;, and margin: 10px;. Which CSS change ensures they fit exactly without wrapping?
hard
A. Remove padding from boxes
B. Increase container width to 600px
C. Set box-sizing: border-box; on the boxes
D. Set margin to 0 on boxes
Solution
Step 1: Calculate total width per box without box-sizing