Right Margin

Many times we would need to set margin for our objects. margin-right will set the right margin of the object.
 
Usage:
margin-right: 10px;
margin-right: 10pt;
margin-right: 10%;
margin-right: auto;
 
It takes the following values:
 
  1. pt: You can set values in points. (e.g: 10pt or 100pt).
  2. px: You can set values in pixels. (e.g: 10px or 100px).
  3. %: You can set values in percentage. (e.g: 10% or 100%).
  4. auto: This will set a automatic / default margin.
 
The following CSS code example shows how to set the value of the right margin:
 
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
 <HEAD>
  <TITLE>CSS Mragin example</TITLE>
  <style type=”text/css”>
 .rightmargin
{
margin-right: 10cm
}
</style>
</head><body>
<p>
This paragraph does not have a specified margin.
</p>
<p class=”rightmargin”>
This paragraph has a right margin of 10cm.
</p>
</body>

</html>

 
Click example to view the page produced by above code.
 
 
CSS Margin Properties
 
Property Description Values
margin A shorthand property for setting the margin properties in one declaration margin-top
margin-right
margin-bottom
margin-left
margin-bottom Sets the bottom margin of an element auto
length
%
margin-left Sets the left margin of an element auto
length
%
margin-right Sets the right margin of an element auto
length
%
margin-top Sets the top margin of an element auto
length
%