CSS Right Margin

How to set Right Margin in html using style sheet?

Explanation

Property :

Right Margin

Usage:


margin-right: 10px;
margin-right: 10pt;
margin-right: 10%;
margin-right: auto;

Definition:


Many times we would need to set margin for our objects. This will set the right margin of the object.
It takes the following values.
a) pt : You can set values in points. (e.g: 10pt or 100pt).
b) px : You can set values in pixels. (e.g: 10px or 100px).
c) % : You can set values in percentage. (e.g: 10% or 100%).
d) auto : This will set a automatic / default margin.

Examples


Example 1:


<div align=right style="margin-right: 20px;">testing right margin </div>
Result:

testing right margin

Note: You can see that the text has moved 20 pixels from right margin with align as right.

Example 2:


<div align=right style="margin-right: 30pt;">testing right margin </div>
Result:

testing right margin

Note: You can see that the text has moved 30 points from right margin with align as right.

Example 3:


<div align=right style="margin-right: 20%;">testing right margin </div>
Result:

testing right margin

Note: You can see that the text has moved 20 percentage from right margin with align as right.

Example 4:


<div align=right style="margin-right: auto;">testing right margin </div>
Result:

testing right margin



Ask Questions

Ask Question