Name

left — NN 4 IE 4 CSS 2

Synopsis

Inherited: No

For positionable elements, defines the position of the left edge of an element’s box (content plus left padding, border, and/or margin) relative to the left edge of the next outermost block content container. When the element is relative-positioned, the offset is based on the left edge of the inline location of where the element would normally appear in the content.

CSS Syntax

left: length | percentage | auto

JavaScript Equivalent

left

Value

See the discussion about length values at the beginning of this chapter. Negative lengths may be allowed in some contexts, but be sure to test the results on all browsers. You may also specify a percentage value, which is calculated based on the width of the next outermost container. The setting of auto lets the browser determine the left offset of the element box on its naturally flowing offset within the containing box. Navigator tends to push up against the left edge of the containing box, whereas Internet Explorer renders a bit of margin.

Initial Value

auto

Example

H1 {position: relative; left: 2em}
#logo {position: absolute; left: 80px; top: 30px}

Applies To

All elements.

Object Model Reference

IE

[window.]document.all.elementID.style.offsetLeft

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.