CSS · The box model

margin

Space outside the border. Auto horizontal margins centre a fixed-width block.

Syntax
margin: 16px auto

Example

Try it

More in this group

aspect-ratio border border-radius box-shadow box-sizing height margin-block / margin-inline min-width / max-width

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course