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

No top articles yet