Skip to: content, navigation

left (CSS property)

Spec
Inherited Initial Version
No auto CSS2
Browser support (more…)
IE7+ FF1+ SA1.3+ OP9.2+
Full Full Full Full

Syntax

left: { length | percentage | auto | inherit } ;

Description

For absolutely positioned boxes, this property specifies how far the left margin edge of the box is offset to the right of the left padding edge of its containing block. However, should the value for left be auto (the initial value), the left margin edge of the box is positioned at the left content edge of its containing block.

For relatively positioned boxes, this property specifies how far the left edge of the box is offset to the right of the position it would have had in the normal flow. If both right and left have a value other than auto, the offset is over-constrained. If the direction property is ltr, right will be ignored. If direction is rtl, left will be ignored.

Example

This style rule makes the element with ID "nav" generate an absolutely positioned box at the top left-hand corner of its containing block:

#nav {
  position: absolute;
  top: 0;
  left: 0;
}

Compatibility

Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.0 1.5 2.0 1.3 2.0 3.0 9.2 9.5
Buggy Buggy Full Full Full Full Full Full Full Full Full

Internet Explorer for Windows versions up to and including 6:

  • compute percentage values on the basis of the width of the parent block, rather than that of the containing block
  • don’t support the specification of both the position and the dimensions of an absolutely positioned element using top, right, bottom, and left together; they’ll use the last vertical and horizontal position specified, and need the dimensions to be specified using width and height

Internet Explorer for Windows versions up to and including 7 don’t support the value inherit.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

Search