margin: ***;

  • IE
  • Cr
  • Sf
  • Fx
  • O

The margin property sets the margins around an element.

div {
margin: 5px 10px 15px 20px;

Property Value Explanation
margin length, %, or auto the top, bottom, left, and right margins
  • margin: 2px; : [all sides] margins
  • margin: 2px 4px; : [top, bottom] [left, right] margins
  • margin: 2px 4px 6px; : [top] [left, right] [bottom] margins
  • margin: 2px 4px 6px 8px; : [top] [right] [bottom] [left] margins

The margins and paddings


<title>TAG index</title>

<style type="text/css">

p { background-color: #85b9e9; }

#example1 { margin: 30px; }
#example2 { margin: 30px 60px; }
#example3 { margin: 30px 0 30px 90px; }



<p id="example1">[the margin on all sides:30px]</p>
<p id="example2">[top,bottom:30px] [left,right:60px]</p>
<p id="example3">[top,bottom:30px] [left:90px] [right:0px]</p>



[the margin on all sides:30px]

[top,bottom:30px] [left,right:60px]

[top,bottom:30px] [left:90px] [right:0px]