HTML and CSS Reference
In-Depth Information
Name
margin
Values:
[ <length> | <percentage> | auto ]{1,4}
Initial value:
Not defined
Applies to:
All elements
Inherited:
No
Percentages:
Refer to the width of the containing block
Computed value:
See individual properties
Description:
A shorthand property that defines the width of the overall margin for an element or sets dis-
tinct widths for the individual side margins. Vertically adjacent margins of block-level ele-
ments 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 ele-
ments. Negative margin values are permitted, but caution is warranted because negative val-
ues can cause elements to overlap other elements or to appear to be wider than their parent
elements.
Examples:
h1 {margin: 2ex;}
p {margin: auto;}
img {margin: 10px;}
Search WWH ::




Custom Search