Property | Description | Possible Values | Examples |
---|---|---|---|
margin-top | Declares the top margin for the element. | Lengths, percentages, and the predefined value auto. | div { margin-top:5px; } div { margin-top:15%; } |
margin-right | Declares the right margin for the element. | Lengths, percentages, and the predefined value auto. | div { margin-right:5px; } div { margin-right:15%; } |
margin-bottom | Declares the bottom margin for the element. | Lengths, percentages, and the predefined value auto. | div { margin-bottom:5px; } div { margin-bottom:15%; } |
margin-left | Declares the left margin for the element. | Lengths, percentages, and the predefined value auto. | div { margin-left:5px; } div { margin-left:15%; } |
margin | Shorthand property used to declare all the margin properties at once. | Separate values by a space in the following order (those that are not defined will use inherited or default initial values): margin-top Undeclared values work as further shorthand notation. If only one length value is declared, all four margins will use that length. If two lengths are declared, the top and bottom margins will use the first length while the right and left margins will use the second length. If three lengths are declared, the top margin will use the first length, the right and left margins will use the second length, and the bottom margin will use the third length. | div { margin:5px 12px 4px 7px; } div { margin:5px; } div { margin:5px 10px; } div { margin:5px 7px 4px; } |