Sets the width of the top, right, bottom, and left margins of the object.


{ margin:sMargin}

Possible values


String that specifies up to four of the following space-delimited values:


Any of the range of margin width values available to the margin-top property.


Any of the range of margin width values available to the margin-right property.


Any of the range of margin width values available to the margin-bottom property.


Any of the range of margin width values available to the margin-left property.

The property has a default value of 0 0. It is not inherited.


This is a shorthand property that specifies up to four width values, in the following order: top, right, bottom, left. If one width value is specified, it is used for all four sides. If two width values are specified, the first is used for the top and bottom borders, and the second is used for left and right borders. If three width values are specified, they are used for the top, right/left, and bottom borders, respectively. Negative margins are supported except for top and bottom margins on inline objects.

For inline elements, the top and bottom values are used to compute the border area of a surrounding inline element, if it is present. These values do not contribute to the height of a line.

Margins are always transparent.


The following example uses the margin property to change the margin of the object. This example uses the IMG object as a selector to set the margin of images to 1 centimeter:

    img {margin:1cm}

Standards information

This property is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) Ee371267.xtlink_newWindow(en-us,Expression.40).png.

Applies to

a, abbr, acronym, b, bdo, big, blockquote, body, button, caption, center, cite, code, custom, dd, defaults, del, dfn, div, dl, dt, em, embed, fieldset, font, form, hn, hr, i, iframe, img, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, ins, li, object, ol, p, q, s, span, sub, table, td, th, tt, u, ul, var, xmp

See also



Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.