Name

margin

Synopsis

This shorthand property sets the width of the overall margin for an element or sets the widths of each individual side margin. Vertically adjacent margins of block-level elements are collapsed, whereas inline elements effectively do not take top and bottom margins. The left and right margins of inline elements do not collapse, nor do margins on floated elements. Negative margin values are permitted, but caution is warranted.

Values:

[ <length> | <percentage> | auto ]{1,4} | inherit

Initial value:

not defined

Applies to:

all elements

Inherited:

no

Percentages:

refer to the width of the containing block

Computed value:

see individual properties

Get Cascading Style Sheets: The Definitive Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.