Name
margin — IE4 P/P | IE5 P/Y | NN4 B/B | Op3 Y/-
Synopsis
This sets the size of the overall margin of an element. Vertically adjacent margins of block-level elements are collapsed to be as large as the largest margin, whereas inline elements effectively do not take margins (they are allowed, but have no effect on page layout). Only the left and right margins of inline elements have any effect, and are not collapsed. Margins set on floated elements are not collapsed with other margins under any circumstance. Negative values are permitted, but caution is recommended.
Example
H1 {margin: 2ex;}Values
[ <length> | <percentage> | auto ]{1,4}
Default
not defined for shorthand properties
Inherited
no
Applies to
all elements
Percentage values refer to width of the closest block-level ancestor.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access