Creates an outside spacing on the element. Spacing can be specified in any direction like left, right, top or bottom .
Padding
Almost similar with margin only that it, creates an inner border on the defined element.
Borders
Enclose content within some border line. Border style can be solid, dotted, dashed, double, ridge, none, hidden . Also border-color and border-width can be changed. Example:
p {
border-style: solid;
border-color: red;
}
<!-- in shorthand -->
p { border: solid red }
.margin { margin : 30px;}
<!-- On breaking down this -->
.margn {
margin-top: 30px;
margin-right: 30px;
margin-bottom: 30px;
margin-left: 30px;
}
<!-- the above is similar to padding -->
ToNote the difference: Margin has the border close enough while padding leaves some space between element content and the border.