marginNN 4 IE 4 CSS 1

Inherited: No

This is a shortcut attribute that can set the margin widths of up to four edges of an element with one statement. A margin is space that extends beyond the border of an element to provide extra empty space between adjacent or nested elements, especially those that have border attributes set. You may supply one to four space-delimited margin values. The number of values determines which sides receive the assigned margins.

 
CSS Syntax
 
margin: marginThickness | auto {1,4}
 
Value

This attribute accepts one, two, three, or four values, depending on how many and which margins you want to set. Values for marginThickness can be lengths, percentages of the next outermost element size, or the auto constant. Value quantities and positions are interpreted as follows.

Number of valuesEffect
1All four margin edges set to value
2Top and bottom margins set to the first value, right and left margins set to the second value
3Top margin set to first value, right and left margins set to second value, bottom margin set to third value
4Top, right, bottom, and left margin set, respectively
 
Initial Value

0

 
Example
 
p.highlight {margin: 10px 20px}
 
Applies To

All elements.

 
Object Model Reference
 
[window.]document.getElementById("elementID").style.margin