CSS Margins

      No Comments on CSS Margins

The CSS margin properties are used to determine the space between the elements in the web page. Margins generate spaces between elements.They are a component of box model.There are CSS Margins properties for setting the margin for each side of an element (top, right, bottom, and left).

Handling CSS Margins – for different sides

  • margin-top
  • margin-bottom
  • margin-left
  • margin-right

Value of Margin property

  • auto – the browser calculates the margin.
  • length – specifies a margin in px, pt, cm, etc.
  • % – specifies a margin in %.
  • inherit – specifies that the margin should be inherited from the parent element

Example:

#samplediv
{
margin-top:20px;
margin-bottom:100px;
margin-left:30px;
margin-right:50px;
}
#samplediv2
{
margin-top:80px;
margin-bottom:40px;
margin-left:90px;
margin-right:10px;

}
Hi, i am div 1
Hi, i am div 2

Leave a Reply

Your email address will not be published. Required fields are marked *