Web Design

(Nancy Kaufman) #1

120


Control Whitespace with Margins .............................


2 Within the body declaration,
type margin:0;.
3 Within the existing h1
declaration, type
margin-top:0;.
4 Press.
5 Type margin-bottom:?;,
replacing? with the amount
of bottom margin you want.

1 In your editor, open a
document that contains an
embedded style sheet and an
existing body declaration.

Control Whitespace with Margins


T


he outermost section of the box model is the margin, which represents the space between
elements on the page. CSS contains five properties for setting margins: margin-top, margin-

right, margin-bottom, and margin-left let you set each side individually, whereas the


margin property is a shortcut for setting all four margins together. This shortcut property can take


a single value to set all four margins. You can also provide two values, where the first applies to the


top and bottom and the second to the left and right, or four values, where the first sets the top, the


second the right, the third the bottom, and the fourth the left.


1


2


3


5

Free download pdf