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.
.sidebar { position: fixed; top: 0; left: 0; width: 16rem; }
Try it
Syntax
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;
autowhere it cannot be resolved; forstaticelements,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. Addtransform: translateX(-50%), or useinset-inline: 0; margin-inline: autowith a width. - Over-constrained boxes. If
left,widthandrightare all set, one must give way. In left-to-right textrightis ignored; in right-to-left textleftis ignored. - Right-to-left layouts. Physical properties do not flip with text direction. Use
inset-inline-startfor offsets that should follow reading direction. - Off-screen hiding.
left: -9999pxis an old trick for visually hiding things; prefer a proper visually-hidden class usingclip-pathorposition: absolutewith tiny size. - Smooth animation. Use
transform: translateX(); animatingleftcauses layout on every frame.
Browser support
Supported in every browser for many years.
Related
right,top,bottominset,inset-inlineposition- Lesson: CSS Position