CSS margin is used to set the space between the HTML element tag border and its content. This is single setting shorthand property to set the margin of HTML element.

By using this propert, margin from all the sides can be be given in the single setting.

The syntax for CSS margin is:

CSS margin values formats

There are different formats you can give the margin value

A single value format.

This will define the same value for all the sides. By using this you can give value for all the sides with just a single format.

Output

This is the HTML paragraph inside the div for background size text. This div used to show the border top. This border has given here to display border.

This will define 10px margin for all the sides.

A double value format.

This will define the two value for all the sides. The first value is for top and bottom, the second value is for left and right. By using this you can give value for all the sides with two value format.

Output

This is the HTML paragraph inside the div for background size text. This div used to show the border top. This border has given here to display border.

This will define 10px margin for top and bottom and 20px for left and right.

A triple value format.

This will define the three value for all the sides. The first value is for top, the second value is for left and right, the third is for bottom. By using this you can give value for all the sides with three value format.

Output

This is the HTML paragraph inside the div for background size text. This div used to show the border top. This border has given here to display border.

This will define 10px margin for top, 20px for left and right and 10px for bottom.

A four value format.

This will define the four value for all the sides. The first value is for top, second for right, third for bottom and fourth is for left. By using this you can give value for all the sides with four value format.

Output

This is the HTML paragraph inside the div for background size text. This div used to show the border top. This border has given here to display border.

This will define 10px margin for top, 30px for right, 10px for bottom and 30px for left.