Margin Collapse



In the above exercise, it says “Unlike horizontal margins, vertical margins do not add. Instead, the larger of the two vertical margins sets the distance between adjacent elements.”
So, what if two margins have same distance, let’s say 20px?


It will still use both. If you would inspect your html using f12, we still see that both css is applied to the corresponding elements.
Its just that the browser doesn’t add the heights. So it will automaticly disable 1 of them.


Thanks, it was very helpful.