HTML CSS IMAGES LINKS
 
CSS → Margins

The area sorounding every element in an HTML document can be defined as a rectangular box which has a content area surrounded by padding, a border and margins.

Margin properties specify the width of the margin area of a box. A margin is the invisible space soronding a box.

This text is set inside a DIV with margins set to 55pixels

Notice how the 55 pixels margins sorround the DIV

The code:

<div style="margin:55px">
<p>This text is set inside a DIV with a margin of 55pixels
</div>

We could have specified the margins of the <p> tag instead:

This text is set inside a <p> with margins set to 55pixels

The code:

<p style="margin:55px;">This text is set inside a <p> with margins set to 55pixels</p>

Note that margin properties specify the width of the margin area of a box. The 'margin' shorthand property sets the margin for all four sides while the other margin properties only set their respective side.

You may use margin-top, margin-right, margin-bottom, and/or margin-left to selectively control any of the margins.

 
  back ↑