Skip to main content
CSS Bug Hunt Medium +20 XP

Margin Collapsing

Two vertical margins of 20px overlap giving 20px, not 40px.

CSSFind the bug
1.box1 { margin-bottom: 20px; }
2.box2 { margin-top: 20px; }
The bug is on line 1

Select the correct fix

Show answer and explanation

Answer: Both A and C prevent collapsing

Vertical margins collapse between block elements. Flex/grid containers prevent collapsing, as does adding overflow: hidden.

Hint: Adjacent vertical margins merge in normal flow.

What this challenge tests

Bug Hunt in CSS: margin-collapse, layout.

Related challenges