On this page
  1. margin
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

margin

Prev: `box-sizing` | Up: box_model | Next: `padding`
Rel: box_model, Box Model & Sizing Guide
Ref: MDN Web Docs — margin
Tags: #public #web #css #properties #box_model #tier/core


Syntax & Overview

margin: 0 auto;  /* logical: margin-inline, margin-block */

Outer spacing outside the border edge; vertical block margins collapse in normal flow.

Notes & Best Practices

Example

.centered-card {
  max-inline-size: 36rem;
  margin-inline: auto;
  margin-block: 2rem;
}

Linked from

Related notes