Version: Level 1
Compability: IE4+ N4+
| Length | Abbrev. |
|---|---|
| centimeters | cm |
| ems | em |
| inches | in |
| millimeters | mm |
| picas | pc |
| pixels | px |
| points | pt |
The margin property is a shortcut for setting the margin-bottom, margin-left, margin-right, and/or margin-top properties in one declaration. This property is not inherited.
You can declare one, two, three or four values. If you omit one of the values, the value for that margin will be obtained from the opposite side, therefore:
If you declare one value, the size for all four margins will be that value.
If you declare two values, the top and bottom margins will be set by the first value, the right and left margins by the second.
If you declare three values, the top margin will be set by the first value, the right and left margins will be set by the second, and the bottom by the third.
If you declare four values, the order is top, right, bottom, left.
body { margin: 25mm; }
body { margin: 1.0in; }
body { margin: 15pc 25pc; }
body { margin: 36pt 24pt 36pt; }
body { margin: 11.5%; }
body { margin: 10% 10% 10% 10%; }
body { margin: auto; }<p style="margin: 1in 1in 1in 1in;">This sentence has a margin of one inch on all sides.</p>This sentence has a margin of one inch on all sides.