Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy.
OK
Specifies a shorthand property for setting the top, right, bottom and left margins, in that order.
The margin property is nearly equivalent to the padding property. Both insert space around an element,
but while padding inserts the space within, margin inserts it around the border of the element.
JavaScript page for this property: margin. You can find other example(s) there.
Possible values:
One of the following values:
This value can be used from 1 to 4 times (use the space character to separate them)
Default. The sizes of the 'auto' margins are equal.
inherit
Takes the value of this property from the computed style of the parent element.
size in length
The size of the margin in length units. For the supported length units, see the length page.
size in percentage
The size is the specified percentage of the width of the parent element.
Default: this property has no default value.
If only onemargin value is set, it is used for all four margins.
If twomargin values are specified, the first value is used for the top and bottom margins, the second one is for the left and right margins.
If threemargin values are set, the first value is used for the top margin, the second one is for the left and right margins and the third one is for the bottom margin.
If fourmargin values are specified, the order is top, right, bottom, left (clockwise from top).
Example HTML code 1:
This example illustrates the use of the border, margin and padding properties: