CSS/Properties/margin-left

From Web Education Community Group
Jump to: navigation, search

margin-left

The margin-left property sets the left margin of a box.

Description

Values [<length> | <percentage> | auto] | inherit
Initial value 0
Applies to all elements except elements with table display types other than table-caption, table and inline-table
Inherited No


Values

  • <length>


  • <percentage>


  • auto


  • inherit
    Takes the same specified value as the property for the element's parent.


Example

Example A

[style.css]

 #body{
   background-color: #666;
 }
 p{
   background-color: #ccc;
 }
 #mar{
   margin-top: 50px;
   margin-right: 10px;
   margin-bottom: 50px;
   margin-left: 10px;
 }

[index.html]

<body>
  <p>This is a paragraph</p>
  <p id="mar">This is a paragraph</p>
  <p>This is a paragraph</p>
  <p>This is a paragraph</p>
</body>

Csslist2 margin.png

CSS Reference

The CSS specification defines the margin-left property in 8.3 Margin properties.

See also