HTML & CSS · Senior · Question 27 of 75
What conditions make the vertical margins of a parent and its first child collapse?
- 1Only if the parent has
display: flexorgrid - 2Only if both margins are negative or zero
- ✓Correct answer: If no
border,paddingor text separates them and there's no BFC
Explanation
The first child's margin-top "falls through" outside the parent if nothing separates them. Collapsing is prevented by padding or border on the parent, display: flow-root, or a flex/grid container - margins inside those never collapse. With negative values, the result is the largest positive plus the most negative.