Skip to content
CSS·Advanced·Conceptual·1 min read

Do flex and grid item margins collapse the way block-level margins do?

Short interview answer

No. Margin collapsing is specific to block formatting contexts; margins on flex items and grid items never collapse with each other, which is one reason gap is often preferred for consistent spacing in those layouts.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to The CSS box model

Related questions