Export (0) Print
Expand All

margin

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

{ margin: sMargin }

sMargin

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

top

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

right

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

bottom

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

left

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:

<style>
    img {margin:1cm}
</style>

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

Community Additions

ADD
Show:
© 2014 Microsoft