CSS margin Property Reference

The CSS margin property is a standard property in CSS Box Model. Review its formal syntax, computed behavior, and practical declarations.

CSS margin Property Reference

The CSS margin property is a standard property in CSS Box Model. Review its formal syntax, computed behavior, and practical declarations.

Updated 2026-08-12

margin overview

The CSS margin property is a standard property in CSS Box Model. Review its formal syntax, computed behavior, and practical declarations.

The property is not inherited by default. Use an explicit global keyword when inheritance is intended.

Syntax and formal definition

margin formal syntax
FieldValue
Formal syntax<'margin-top'>{1,4}
Initial valuemargin-bottom, margin-left, margin-right, margin-top
Applies toallElementsExceptTableDisplayTypes
InheritedNo
PercentagesreferToWidthOfContainingBlock
Computed valuemargin-bottom, margin-left, margin-right, margin-top
Animation typelength
Mediavisual
Specification groupCSS Box Model
StatusStandard

Practical examples

These declarations demonstrate valid ways to set margin. The initial and inherit global keywords remain available even when a property-specific value is preferable.

margin live example
CSS .reset-example { margin: initial; } .inherit-example { margin: inherit; } @supports (margin: 1rem) { .supported { margin: 1rem; } }

Description

The CSS margin property is a standard property in CSS Box Model. Review its formal syntax, computed behavior, and practical declarations.

References

  1. MDN: margin
  2. MDN: CSS Properties Reference

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies