CSS left Property
CSS left property specifies the left position of an element in combination with the position property.
If position: absolute; or position: fixed;: The left property sets the left position of an element to a unit to the left of the left position of its nearest positioned ancestor.
Usages
The following table outline the usages and version history of this property.
| Default value: | auto |
| Applies to: | Positioned elements |
| Inherited: | No |
| Version: | CSS2 |
| JavaScript Syntax: | object.style.left = "15px" |
Syntax
Here is a syntax for the CSS left property
left: auto | length | percentage | initial | inherit;
Property Values
The following table describes the values of this property.
| Value | Description |
|---|---|
| auto | Default. Browser will calculate the left position for the element |
| length | Specifies the length value expressed in px, pt, cm, em, etc. to set left position Negative values are allowed. |
| percentage | Specifies the percentage value to set left position |
| initial | Sets default value of this property |
| inherit | Inherits this property from its parent element |
Examples
The example below shows to sets left property.
div.one {
left: 10%;
position: absolute;
}
div.two {
left: 0;
position: absolute;
}
Browser Compatibility
- Google Chrome 1+
- Mozilla Firefox 1+
- Internet Explorer 5+
- Opera 6+
- Safari 1+
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.