Josh Comeau 12/7/2020

The Rules of Margin Collapse

Read Original

This article is a comprehensive guide to the often-confusing CSS behavior known as margin collapse. It explains the core rules, such as only vertical margins collapsing and the largest margin winning. It also details the specific circumstances that prevent collapsing, like padding, borders, and scroll containers, helping developers predict and control layout behavior.

The Rules of Margin Collapse

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

2
Designing Design Systems
TkDodo Dominik Dorfmeister 2 votes
4
Introducing RSC Explorer
Dan Abramov 1 votes
6
Fragments Dec 11
Martin Fowler 1 votes
7
Adding Type Hints to my Blog
Daniel Feldroy 1 votes
8
Refactoring English: Month 12
Michael Lynch 1 votes
10