Search notes:

CSS: margin property

1 to 4 values

The margin property can be set to 1 through 4 values, each of which is separated by white spaces.
Depending on the number of values given, they specify:
#elem_1  {     /* Margin with four values:   */
  margin:  5px /*   top                      */
           7px /*   right                    */
           6px /*   bottom                   */
           4px /*   left                     */
}

#elem_2  {     /* Margin with three values:  */
  margin:  5px /*   top                      */
           7px /*   right, left              */
           6px /*   bottom                   */
}

#elem_3  {     /* Margin with two values     */
  margin:  5px /*   top, bottom              */
           6px /*   left, right              */
}

#elem_4  {     /* Margin with one value      */
  margin:  5px /*   top, bottom, left, right */
}

Margin-collapsing

No collapsing occurs for elements that are

See also

The padding and border properties
The influence of margin-top on the HTML element <ul>.
The CSS box model
More CSS properties

Index