Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style left Property

Style left Property

Style Object Reference The Style object


Definition and Usage

The left property sets or returns the left position of a positioned element.

This property specifies the left position of the element, including: padding, scrollbar, border and margin.

**Tip:** A positioned element is an element whose position property is set to: relative, absolute, or fixed.

Syntax

Sets the left property:

Object.style.left="auto|

length

|

%

|inherit"

Returns the left property:

Object.style.left

Value Description
auto Default. The left position is calculated by the browser.
length Defines the left edge of the element relative to the left edge of the nearest positioned ancestor, using units such as px, cm, etc. Negative values are allowed.
% Defines the left edge of the element as a percentage of the left edge of the nearest positioned ancestor.
inherit The left property value is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the left property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Sets the left position of a button:

Try it »


Style Object Reference The Style object