← Back to properties
CSS Property
margin
SpacingSets the space outside an element's border, separating it from neighboring elements.
Syntax
margin: value;
Example
margin: 0 auto;
Common use cases
- Centering block elements horizontally with margin: 0 auto
- Adding space between sections
- Collapsing margins between stacked elements
Practical developer insight
Vertical margins collapse — if two stacked elements both have margin, only the larger one applies, not the sum.