Using the Margin Property


By using the margin property, you can set all four margins at once. Here's how it works:

  • If only one value is set on this property, that value applies to all four sides.

  • If two values are set, the first is for top and bottom, the second is for right and left. For example, suppose the value is 3em 2em; in that case, the top and bottom are set to 3em, and the right and left are set to 2em.

  • If three values are set, the first is the top, the second are the right and left, and the third is the bottom margin.

  • If four values are set on this property, the order they are applied is top, right, bottom, and left.

The following are examples of rules for using the margin property in these various ways:

 /* All margins will be 2 em */ BODY { margin: 2em } /* The top and bottom margins will be 1 em, and    the right and left margins will be 2 em. */ BODY { margin: 1em 2em } /* The top margin will be 1 em, the right and left    will be 2 em, and the bottom margin will be 3 em. */ BODY { margin: 1em 2em 3em } /* All margins will be set, and values will be    applied in top/right/bottom/left order. */ BODY { margin: 1em 3em 5em 7em }



Cascading Style Sheets(c) Designing for the Web
Cascading Style Sheets: Designing for the Web (3rd Edition)
ISBN: 0321193121
EAN: 2147483647
Year: 2003
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net