CSS left Property

The CSS left property specifies the left inset of a positioned element, controlling its horizontal placement relative to its containing block or normal position.

Its behavior depends on the element's position value. It can move relatively positioned elements, establish offsets for absolutely or fixed-positioned elements, and define a sticky positioning threshold. The property has no positioning effect on elements using position: static.

left Syntax

The left property accepts length values, percentages, auto, and supported CSS sizing or calculation expressions.

Basic Syntax

selector {
  left: 20px;
}

Length Values

.element {
  left: 20px;
}
.element {
  left: 2rem;
}
.element {
  left: 5em;
}
.element {
  left: 10vw;
}

Percentage Values

.element {
  left: 10%;
}
.element {
  left: 50%;
}

Automatic Positioning

.element {
  left: auto;
}

Negative Values

.element {
  left: -20px;
}
.element {
  left: -10%;
}

Calculated Values

.element {
  left: calc(50% - 100px);
}
.element {
  left: clamp(10px, 5vw, 60px);
}
.element {
  left: var(--horizontal-offset);
}

CSS-Wide Keywords

.element {
  left: initial;
}
.element {
  left: inherit;
}
.element {
  left: unset;
}
.element {
  left: revert;
}
.element {
  left: revert-layer;
}

The initial value is auto. A non-auto value affects positioning only when the element uses an applicable non-static positioning mode.

Property Values

The following values determine the left offset of a positioned element.

Value Description
auto Lets the positioning algorithm determine the left inset.
<length> Specifies a fixed or relative length, such as 20px, 2rem, or 5vw.
<percentage> Specifies an offset relative to the containing block's width.
calc() Calculates an offset using compatible lengths and percentages.
min() Uses the smallest value from a set of compatible expressions.
max() Uses the largest value from a set of compatible expressions.
clamp() Constrains an offset between a minimum and maximum value.
anchor() Uses an anchor-positioning reference where supported.
initial Resets the property to auto.
inherit Uses the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Positioned elements
Computed value Specified length, percentage, or auto, with supported calculations resolved as applicable
Animation type Length, percentage, or calculated value
Percentages Relative to the containing block's width
Physical axis Horizontal
Related properties right, top, bottom, inset, position

The effect of left depends on the positioning mode, the containing block, and any competing horizontal sizing or inset constraints.

How It Works

The left property participates in positioning an element along the horizontal axis. Its meaning differs between relative positioning and the other positioning modes.

Relative Positioning

.element {
  position: relative;
  left: 20px;
}

The element moves 20 pixels to the right from its normal position while retaining its original space in the document layout.

Absolute Positioning

.container {
  position: relative;
}
.element {
  position: absolute;
  left: 20px;
}

The element's left margin edge is positioned 20 pixels from the containing block's left padding edge in this typical case.

Fixed Positioning

.element {
  position: fixed;
  left: 20px;
}

The element is positioned 20 pixels from the left edge of its fixed-position containing block, which is usually the viewport.

Sticky Positioning

.element {
  position: sticky;
  left: 0;
}

The left inset establishes a sticky positioning threshold relative to the relevant scrollport.

Important Consideration

The property does not always move an element by the specified distance. With absolute and fixed positioning, it establishes a positioning constraint relative to a containing block.

Positioning Modes

The position property determines whether and how left affects an element.

Position Value Effect of left
static No positioning effect.
relative Offsets the element from its normal position.
absolute Establishes a left inset relative to its absolute-position containing block.
fixed Establishes a left inset relative to its fixed-position containing block.
sticky Defines a horizontal sticky threshold relative to the relevant scrollport.

Positioning Example

.static-item {
  position: static;
  left: 20px;
}
.relative-item {
  position: relative;
  left: 20px;
}
.absolute-item {
  position: absolute;
  left: 20px;
}
.fixed-item {
  position: fixed;
  left: 20px;
}
.sticky-item {
  position: sticky;
  left: 20px;
}

The same left value can produce different results because each positioning mode follows different layout rules.

Static Positioning

Elements use position: static by default. In this mode, the left property has no positioning effect.

Static Element

.element {
  position: static;
  left: 50px;
}

The element remains in its normal document position.

Enable Positioning

.element {
  position: relative;
  left: 50px;
}

Changing the positioning mode allows the offset to affect the element.

Important Consideration

When left appears ineffective, check the element's computed position value first.

Relative Positioning

With position: relative, the left property moves an element horizontally from its normal position without removing it from the document flow.

Move Right

.element {
  position: relative;
  left: 30px;
}

A positive value moves the element 30 pixels to the right.

Move Left

.element {
  position: relative;
  left: -30px;
}

A negative value moves the element 30 pixels to the left.

Combine Horizontal and Vertical Offsets

.element {
  position: relative;
  left: 20px;
  top: 10px;
}

The element moves 20 pixels right and 10 pixels down from its normal position.

Document Flow

Relative positioning does not change the space reserved for the element. Nearby elements remain laid out as though the element had not moved.

Important Consideration

Large relative offsets can cause elements to overlap neighboring content because the original layout space is preserved.

Absolute Positioning

With position: absolute, the left property establishes the element's left inset relative to its absolute-position containing block.

Position Inside a Container

.container {
  position: relative;
  width: 400px;
  height: 200px;
}
.element {
  position: absolute;
  left: 20px;
  top: 20px;
}

The element is positioned 20 pixels from the container's left padding edge and 20 pixels from its top padding edge, assuming ordinary margins and no conflicting constraints.

Position at the Left Edge

.element {
  position: absolute;
  left: 0;
  top: 0;
}

Position at a Percentage Offset

.element {
  position: absolute;
  left: 50%;
  top: 20px;
}

The element's left inset is 50% of the containing block's width. This does not automatically center the element.

Center with a Transform

.element {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

The percentage inset moves the element's left edge to the horizontal midpoint, while the transform shifts the element left by half its own width.

Important Consideration

Absolutely positioned elements are removed from normal document flow. Their positioning does not reserve space among neighboring in-flow elements.

Fixed Positioning

With position: fixed, the left property establishes an inset relative to the fixed-position containing block.

Fixed Left Offset

.element {
  position: fixed;
  left: 20px;
  top: 20px;
}

The element is normally positioned 20 pixels from the left and top edges of the viewport.

Fixed Bottom-Left Element

.notification {
  position: fixed;
  left: 20px;
  bottom: 20px;
}

This pattern can be used for notifications or utility controls that remain visible during scrolling.

Fixed Side Panel

.side-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
}

The panel extends along the left side of the viewport in the typical case.

Important Consideration

Some ancestors, including elements with certain transforms, can establish a fixed-position containing block. In those situations, the element may be positioned relative to that ancestor rather than the viewport.

Sticky Positioning

With position: sticky, the left property defines a horizontal inset threshold relative to the nearest relevant scrollport.

Sticky Left Edge

.sticky-column {
  position: sticky;
  left: 0;
}

This is useful for keeping a column visible while horizontally scrolling a wide table or layout.

Sticky Table Column

.table-wrapper {
  overflow-x: auto;
}
.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  background-color: #fff;
  z-index: 1;
}

The first column can remain aligned with the left edge of the scrolling area as the remaining columns scroll horizontally.

Sticky Offset

.sticky-column {
  position: sticky;
  left: 20px;
}

The element uses a 20-pixel left sticky threshold when horizontal scrolling would otherwise move it beyond that position.

Important Consideration

Sticky positioning requires a non-auto inset on the relevant axis and enough scrollable space for the sticky behavior to become visible. The element also remains constrained by its containing block.

Length Values

The left property accepts CSS length units, including absolute and relative lengths.

Pixels

.element {
  position: absolute;
  left: 24px;
}

Root-Relative Units

.element {
  position: absolute;
  left: 2rem;
}

Element-Relative Units

.element {
  position: absolute;
  left: 3em;
}

Viewport Units

.element {
  position: fixed;
  left: 5vw;
}

Container Query Units

.container {
  container-type: inline-size;
  position: relative;
}
.element {
  position: absolute;
  left: 10cqw;
}

Container query units can make offsets responsive to the size of a query container.

Important Consideration

Choose units according to the intended behavior. Pixels provide a fixed CSS length, while relative units can adapt to typography, viewport dimensions, or container size.

Percentage Values

Percentage values for left are resolved relative to the width of the containing block.

Ten Percent Offset

.container {
  position: relative;
  width: 400px;
}
.element {
  position: absolute;
  left: 10%;
}

In this example, the left inset is 40 pixels.

Halfway Across the Container

.element {
  position: absolute;
  left: 50%;
}

The element's left edge is positioned at the horizontal midpoint of its containing block, assuming ordinary margins and no conflicting constraints.

Full-Width Offset

.element {
  position: absolute;
  left: 100%;
}

This positions the element's left edge at the containing block's right edge in the typical case.

Important Consideration

The percentage is based on the containing block's width, not the positioned element's own width. Use a transform or another alignment technique when the element must be centered around a percentage position.

auto Value

The auto value allows the browser's positioning algorithm to determine the left inset based on the positioning mode and other constraints.

Automatic Left Inset

.element {
  position: absolute;
  left: auto;
}

Position from the Right

.element {
  position: absolute;
  left: auto;
  right: 20px;
}

The element is positioned using the right inset rather than an explicitly specified left inset.

Reset a Previous Offset

.element {
  position: absolute;
  left: 30px;
}
.element.reset {
  left: auto;
}

Important Consideration

auto does not always mean zero. Its used value depends on the positioning algorithm, available space, and other inset or sizing declarations.

Negative Values

The left property accepts negative lengths and percentages, allowing positioned elements to extend toward or beyond the left side of their reference area.

Negative Relative Offset

.element {
  position: relative;
  left: -20px;
}

The element moves 20 pixels left from its normal position.

Negative Absolute Offset

.container {
  position: relative;
}
.element {
  position: absolute;
  left: -20px;
}

The element's left margin edge is placed 20 pixels outside the containing block's left padding edge in the typical case.

Negative Percentage

.element {
  position: absolute;
  left: -10%;
}

The negative offset is calculated relative to the containing block's width.

Important Consideration

Negative offsets can create overflow or overlap. Check the result at different viewport sizes and ensure that important content remains accessible.

Calculated Values

CSS mathematical functions allow the left property to combine measurements and respond to changing layout dimensions.

Using calc()

.element {
  position: absolute;
  left: calc(50% - 100px);
}

This places the element 100 pixels to the left of the containing block's horizontal midpoint.

Using min()

.element {
  position: absolute;
  left: min(5vw, 40px);
}

The smaller of the two values is used.

Using max()

.element {
  position: absolute;
  left: max(16px, 3vw);
}

The larger value establishes the offset.

Using clamp()

.element {
  position: absolute;
  left: clamp(16px, 5vw, 64px);
}

The offset adapts to viewport width while remaining between 16 and 64 pixels.

Using Custom Properties

:root {
  --panel-offset: 24px;
}
.panel {
  position: fixed;
  left: var(--panel-offset);
}

Important Consideration

Calculations must produce a valid length-percentage value. The browser evaluates the expression according to the units and reference dimensions involved.

Containing Block

The containing block provides the reference area used to calculate the left inset for absolutely and fixed-positioned elements.

Positioned Ancestor

.container {
  position: relative;
  width: 400px;
  height: 200px;
}
.element {
  position: absolute;
  left: 30px;
  top: 20px;
}

The positioned ancestor establishes the containing block for the absolutely positioned child.

No Positioned Ancestor

.element {
  position: absolute;
  left: 30px;
}

Without an ancestor that establishes an absolute-position containing block, the element is positioned relative to the initial containing block.

Fixed Containing Block

.element {
  position: fixed;
  left: 30px;
}

Fixed positioning normally uses the viewport as its containing block.

Transformed Ancestor

.container {
  transform: translateZ(0);
}
.element {
  position: fixed;
  left: 30px;
}

A transformed ancestor can establish a containing block for fixed-positioned descendants, changing how their offsets are resolved.

Important Consideration

Containing blocks are not determined only by position: relative. Other properties, including certain transforms and containment settings, can also establish them.

left and right Together

The left and right properties can work together to constrain the horizontal position and size of an element.

Stretch Across a Container

.container {
  position: relative;
}
.element {
  position: absolute;
  left: 20px;
  right: 20px;
  width: auto;
}

With ordinary auto sizing and no conflicting constraints, the element fills the available horizontal space between the two insets.

Fixed Width with Both Insets

.element {
  position: absolute;
  left: 20px;
  right: 20px;
  width: 150px;
}

The specified constraints may become over-constrained. In a horizontal left-to-right containing block, the used right inset is adjusted. In a right-to-left containing block, the used left inset is adjusted.

Relative Positioning

.element {
  position: relative;
  left: 20px;
  right: 10px;
}

When both horizontal offsets are specified for a relatively positioned element, they cannot independently determine its movement. In a left-to-right direction, left takes precedence; in a right-to-left direction, right takes precedence.

Important Consideration

When both insets are specified, the final result depends on the positioning mode, width, margins, direction, and applicable constraint-solving rules.

left and width

The left property controls an inset, while width controls the element's horizontal size. They are related but serve different purposes.

Fixed Width and Offset

.element {
  position: absolute;
  left: 40px;
  width: 200px;
}

Responsive Width

.element {
  position: absolute;
  left: 20px;
  width: calc(100% - 40px);
}

This example gives the element a width based on the containing block while leaving space at both sides, assuming ordinary box-sizing and no additional constraints.

Use Both Horizontal Insets

.element {
  position: absolute;
  left: 20px;
  right: 20px;
  width: auto;
}

This can be simpler than manually calculating the width.

Important Consideration

Padding, borders, margins, minimum widths, and maximum widths can affect the final used dimensions. Test constrained layouts at narrow viewport sizes.

Writing Modes and Direction

The left property is a physical inset. It always refers to the physical left side, regardless of the writing mode or text direction.

Left-to-Right Layout

.container {
  direction: ltr;
  position: relative;
}
.element {
  position: absolute;
  left: 20px;
}

Right-to-Left Layout

.container {
  direction: rtl;
  position: relative;
}
.element {
  position: absolute;
  left: 20px;
}

The offset still refers to the physical left side, even though the inline-start side is on the right.

Vertical Writing Mode

.container {
  writing-mode: vertical-rl;
  position: relative;
}
.element {
  position: absolute;
  left: 20px;
}

The property continues to use the physical left edge. It does not automatically follow the inline-start or block-start side.

Important Consideration

Use logical inset properties when an offset should adapt to the writing mode and direction. Physical properties are appropriate when positioning must remain tied to a particular physical side.

Physical and Logical Offsets

CSS provides logical inset properties that map to physical sides according to writing mode and direction.

Physical Left Offset

.element {
  position: absolute;
  left: 20px;
}

Logical Inline-Start Offset

.element {
  position: absolute;
  inset-inline-start: 20px;
}

In a horizontal left-to-right layout, inset-inline-start corresponds to left. In a horizontal right-to-left layout, it corresponds to right.

Logical Block-End Offset

.element {
  position: absolute;
  inset-block-end: 20px;
}

In a vertical writing mode, a block-axis inset can correspond to a physical horizontal side.

Physical and Logical Comparison

Property Reference Side
left Physical left
right Physical right
inset-inline-start Logical inline-start
inset-inline-end Logical inline-end
inset-block-start Logical block-start
inset-block-end Logical block-end

Important Consideration

When physical and logical properties target the same side, the CSS cascade determines which declaration wins. Avoid conflicting declarations unless an intentional fallback is required.

inset Shorthand

The inset shorthand sets the top, right, bottom, and left properties together.

One Value

.element {
  position: absolute;
  inset: 20px;
}

All four inset properties are set to 20 pixels.

Two Values

.element {
  position: absolute;
  inset: 10px 20px;
}

The top and bottom insets are 10 pixels, while the right and left insets are 20 pixels.

Four Values

.element {
  position: absolute;
  inset: 10px 20px 30px 40px;
}

This is equivalent to:

.element {
  top: 10px;
  right: 20px;
  bottom: 30px;
  left: 40px;
}

Override the Left Inset

.element {
  position: absolute;
  inset: 20px;
  left: 40px;
}

The later left declaration overrides the left value established by the shorthand.

Important Consideration

The inset shorthand follows the same one-to-four-value pattern as margin and padding. It controls physical inset properties rather than logical sides.

Stacking and Overflow

Changing an element's left offset can affect overlap, visibility, and horizontal overflow.

Overlapping Elements

.element {
  position: relative;
  left: 40px;
}

The element moves visually but keeps its original layout space, so it may overlap nearby content.

Absolute Positioning and Overflow

.container {
  position: relative;
  overflow: hidden;
}
.element {
  position: absolute;
  left: -30px;
}

The element may extend outside the container, with overflowing portions clipped by the container's overflow behavior.

Stacking Order

.element {
  position: absolute;
  left: 20px;
  z-index: 2;
}

The z-index property can affect which positioned element appears above another, subject to stacking context rules.

Important Consideration

The left property does not directly control stacking order. Use appropriate stacking and overflow properties when positioned elements overlap or extend outside their containers.

Inheritance

The left property is not inherited. Its initial value is auto.

Parent Offset

.parent {
  position: relative;
  left: 30px;
}

The child does not automatically inherit left: 30px, although it may move visually with its positioned parent.

Explicit Inheritance

.child {
  position: relative;
  left: inherit;
}

The child uses the parent's computed left value.

Reset to Initial Value

.element {
  left: initial;
}

This resets the property to auto.

Using unset

.element {
  left: unset;
}

Because left is not inherited, unset behaves like initial.

Important Consideration

An element can move because its ancestor moves without inheriting the ancestor's left property. These are separate layout effects.

left Example

This example compares positive and negative relative offsets with absolute positioning. Each demonstration uses a visible reference area to show how the left property affects the element's placement.

HTML Example

<div class="left-demo">
  <div class="demo-row">
    <h3>position: relative; left: 30px;</h3>
    <div class="demo-area">
      <div class="demo-item relative-positive">Item</div>
    </div>
  </div>
  <div class="demo-row">
    <h3>position: relative; left: -20px;</h3>
    <div class="demo-area">
      <div class="demo-item relative-negative">Item</div>
    </div>
  </div>
  <div class="demo-row">
    <h3>position: absolute; left: 30px;</h3>
    <div class="demo-area">
      <div class="demo-item absolute-positive">Item</div>
    </div>
  </div>
  <div class="demo-row">
    <h3>position: absolute; left: 50%;</h3>
    <div class="demo-area">
      <div class="demo-item absolute-percent">Item</div>
    </div>
  </div>
</div>

CSS Example

.left-demo .demo-row {
  margin-bottom: 20px;
}
.left-demo h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.left-demo .demo-area {
  position: relative;
  height: 80px;
  padding: 15px 25px;
  border: 2px solid #2563eb;
  background-color: #eff6ff;
  overflow: visible;
}
.left-demo .demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 40px;
  background-color: #2563eb;
  color: #fff;
  font-weight: bold;
}
.left-demo .relative-positive {
  position: relative;
  left: 30px;
}
.left-demo .relative-negative {
  position: relative;
  left: -20px;
}
.left-demo .absolute-positive {
  position: absolute;
  left: 30px;
  top: 15px;
}
.left-demo .absolute-percent {
  position: absolute;
  left: 50%;
  top: 15px;
}
Browser Result

position: relative; left: 30px;

Item

position: relative; left: -20px;

Item

position: absolute; left: 30px;

Item

position: absolute; left: 50%;

Item

The first two examples move elements from their normal positions. The last two examples use absolute positioning, placing the elements relative to their containing blocks.

Try a Negative Absolute Offset

.left-demo .absolute-positive {
  left: -10px;
}

The absolutely positioned item extends toward the left side of its containing block.

Try Horizontal Centering

.left-demo .absolute-percent {
  left: 50%;
  transform: translateX(-50%);
}

The item becomes centered around the containing block's horizontal midpoint.

Common Mistakes

Using left Without Positioning

.element {
  left: 20px;
}

Without a non-static positioning mode, the declaration does not change the element's position.

Assuming Positive Values Always Move Right

For relatively positioned elements, a positive left offset moves the element right. For absolutely positioned elements, it establishes a left inset relative to the containing block.

Using left: 50% to Center an Element

.element {
  position: absolute;
  left: 50%;
}

This places the element's left edge at the midpoint. It does not center the entire element.

Forgetting the Containing Block

An absolutely positioned element may be positioned relative to an unexpected ancestor or the initial containing block if the intended container does not establish a positioning reference.

Conflicting left and right Constraints

Specifying left, right, and a fixed width can create an over-constrained layout. The browser resolves the conflict according to the applicable positioning rules.

Expecting Relative Positioning to Reflow Content

Relative offsets move the element visually but preserve its original layout space.

Using Physical Offsets for Direction-Sensitive Layouts

The left property always refers to the physical left side. Use logical inset properties when the offset should follow writing direction.

Ignoring Horizontal Overflow

Large positive or negative offsets can move content outside its container or viewport.

Important Considerations

Keep the following points in mind when using left:

  • The property controls the physical left inset of positioned elements.
  • The initial value is auto.
  • The property is not inherited.
  • It has no positioning effect on elements using position: static.
  • With relative positioning, positive values move the element right and negative values move it left.
  • Relative positioning preserves the element's original space in normal flow.
  • With absolute positioning, left establishes an inset relative to the containing block.
  • Absolutely positioned elements are removed from normal document flow.
  • Fixed positioning normally uses the viewport as its containing block.
  • Certain ancestors can establish containing blocks for fixed-positioned elements.
  • Sticky positioning uses left as a horizontal threshold relative to the relevant scrollport.
  • Length values can use pixels, font-relative units, viewport units, and other supported CSS units.
  • Percentages are calculated relative to the containing block's width.
  • Negative values are valid and may create overflow.
  • calc(), min(), max(), and clamp() can produce responsive offsets.
  • left: 50% does not automatically center an element.
  • Both left and right can participate in horizontal positioning constraints.
  • Width, margins, and sizing constraints can affect the final used position.
  • The property is physical and does not adapt automatically to text direction.
  • inset-inline-start and other logical inset properties provide direction-aware alternatives.
  • The inset shorthand can set all four physical inset properties.
  • Offsets can create overlap or horizontal overflow.
  • The z-index property controls stacking order where applicable, not horizontal placement.
  • Length and percentage offsets can be animated when the applicable values are interpolable.

Browser Support

The CSS left property is widely supported in all modern browsers, including Chrome, Edge, Firefox, Safari, and Opera.

Basic length, percentage, and auto values have long-established support. Newer positioning features, such as CSS Anchor Positioning, have separate compatibility requirements.

For current compatibility information, visit Can I Use? and search for the CSS left property.

Specifications

The left property is defined by the CSS Positioned Layout specification, building on the positioning rules established in CSS 2.1.

CSS Positioned Layout Module Level 3: Inset Properties

The specification describes how inset properties participate in relative, absolute, fixed, and sticky positioning.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: left