margin-left sets the left margin of an element.
Overview tableDepends on the particular element. Different elements have different default margins.
marginLeft
margin-left: auto
margin-left: inherit
margin-left: length
margin-left: percentage
margin-left
width.
In this example there are three blocks, styled identically except for their margin-left
values:
margin-left
of 2 centimeters, meaning that it is pushed over to the right by 2cm.margin-left
of its own, to indicate the default position of the blocks.margin-left
of -10% set on it, meaning that it is pushed over to the left by 10% of the parent element’s width.<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
CSS applied to the HTML shown in the first example.
* {
margin: 0;
}
div {
width: 200px;
height: 100px;
background: linear-gradient(rgba(0,0,0,0.25), rgba(0,0,0,0));
border-radius: 10px;
}
.one {
background-color: red;
margin-left: 2cm;
}
.two {
background-color: blue;
}
.three {
background-color: green;
margin-left: -10%;
}
Usage
===Usage===
margin-bottom
if there is a specific reason to call attention to it (e.g. one element has a different bottom margin than the rest in its class, etc.).You can specify possible length values relative to the height of the element’s font (em
) or the height of the letter “x” (ex
). In Microsoft Internet Explorer 3.0, the specified margin value is added to the default value of the object. In Microsoft Internet Explorer 4.0 and later, the margin value is absolute. The margin properties do not work with the td and tr objects in Internet Explorer 4.0, but they do work in Internet Explorer 3.0. To set margins in the cell for Internet Explorer 4.0 and later, apply the margin to an object, such as div or p, within the td. This property applies to inline elements, starting with Microsoft Internet Explorer 5.5. With earlier versions of Windows Internet Explorer, inline elements must have an absolute position or layout to use this property. Element layout is set by providing a value for the height property or the width property. Negative margins are supported, except for top and bottom margins on inline objects.
margin-left
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4