CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS margin property




The CSS margin property set a margin space of border or contain.


Property Values


Properties Value Description
Syntax margin:value;
value   width
  inherit    Lern More...
Allow to All elements
Inherited No

Example-Code:

<p style="margin:30px;">This example is Margin set space</p>
Online Try This Code Your Self....   »

Example-Result:

This example is Margin set space

CSS Shorthand Margin Style

Example Code:

<p style="border:1px solid orange;margin:25px 25px 5px 50px;width:
300px;">This example is shorthand margin style property value are allow
to display results. border color orange and border style dashed.</p>
Online Try This Code Your Self....   »

Example-Result:

This example is shorthand margin style property value are allow to display results. border color orange and border style dashed.


Margin Set Value

Margin:12px;
All sides have Margin 12 pixels.

Margin:10px 20px;
Top and bottom have Margin 10 pixels.
Right and left have Margin 20 pixels.

Margin:10px 20px 30px;
Top Margin is 10px
Left and right are 20px
Bottom Margin is 30px

Margin:10px 20px 30px 40px;
Top Margin is 10px
Right Margin is 20px
Bottom Margin is 30px
Left Margin is 40px