This property lets you change the width of one or more of the margins around an object.
If you specify only one value, all four margins are set. Two values define the top and bottom with the first, and the second then applies to the left and right. If three values are specified, the first controls the top, the second controls both left and right, while the third controls the bottom edge. When all four values are specified, they are assumed to be in the order: top, right, bottom and left.
Width values can be specified using pixel values, em-dash units or percentages of the next outermost parent object. The auto keyword lets the browser decide for itself.
Although both Netscape Navigator and MSIE support padding and margin control properties. It is not clear from the documentation sources whether they are simply different names for the same thing. Padding is a space that is placed outside the content rectangle of the element's extent. Margins also are not calculated as part of the element's width and height so they appear to be the same thing, although functionally they should be contained inside the extent rectangle, if they behave in a manner consistent with the way that margins are generally assumed to work.
Be wary of using margins and padding in case they undergo a functional change in the future.
Prev | Home | Next |
style.listStyleType | Up | style.marginBottom |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |