Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Positioning and Stacking

The left property

Reference for the CSS left property: how it offsets positioned elements from the left edge, percentages, conflicts with right, and RTL considerations.

The left property sets the horizontal offset of a positioned element from the left edge of its reference box. For relative elements it shifts the box from its normal position (a positive value moves it to the right), for absolute it measures from the padding edge of the nearest positioned ancestor, and for fixed from the viewport.

Like the other physical offsets, left has no effect on position: static elements.

CSS
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 16rem;
}

Try it

Left offsets

Syntax

CSS
left: auto | <length> | <percentage> | <anchor()> | <anchor-size()>;
  • Initial value: auto
  • Applies to: positioned elements
  • Inherited: no
  • Percentages: refer to the width of the containing block
  • Animatable: yes, as a length or percentage
  • Computed value: for positioned elements, an absolute length or a percentage as specified; auto where it cannot be resolved; for static elements, auto

Values

Value Description
auto No horizontal offset from this side; the position comes from right, the width, or normal flow.
<length> A fixed distance from the left edge. Negative values move the element outside the box.
<percentage> A percentage of the containing block's width.
anchor(...) A position taken from an anchor element (see anchor positioning).

Usage notes

  • Centering needs more than left: 50%. That puts the element's left edge at the middle. Add transform: translateX(-50%), or use inset-inline: 0; margin-inline: auto with a width.
  • Over-constrained boxes. If left, width and right are all set, one must give way. In left-to-right text right is ignored; in right-to-left text left is ignored.
  • Right-to-left layouts. Physical properties do not flip with text direction. Use inset-inline-start for offsets that should follow reading direction.
  • Off-screen hiding. left: -9999px is an old trick for visually hiding things; prefer a proper visually-hidden class using clip-path or position: absolute with tiny size.
  • Smooth animation. Use transform: translateX(); animating left causes layout on every frame.

Browser support

Supported in every browser for many years.