Left Property

Last updated: 2026-09-13

left Left Property

The left property defines the offset of a positioned element from the left edge of its containing block, measured rightward. It only applies to non-static positioned elements and is among the most commonly used offset properties, typically paired with absolute or fixed positioning for precise left-side placement.

Category
Initial Valueauto
InheritedNo
Applies To
Animation Type
CSS VersionCSS2
StatusStandard

📝 Syntax

left: auto | <length> | <percentage>;

⚙️ Values

ValueTypeDescription
autoKeywordNo offset.
<length> | <percentage>TypeAn offset from the containing block's left edge.

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
left v1 v12 v1 v1 v1
Supported in all major browsers
Warning: left only affects non-static positioned elements; it has no effect on position:static.
Tip: A percentage is computed against the containing block's width. Setting both left and right stretches the element's width for adaptive layouts.

❓ FAQ

QWhat happens when both left and right are set?
AFor absolute or fixed elements without a width, the element stretches from left to right, filling the horizontal space adaptively; for example, .overlay { position:absolute; left:0; right:0; } spans the full width. If a width is set, left wins and right is ignored in LTR text. This is a go-to pattern for full-width bars and overlay layers, letting the element resize with the viewport automatically.
QWhat is the left percentage relative to?
AThe percentage is computed against the containing block's width. For absolute elements the containing block is the padding box of the nearest positioned ancestor; for fixed it is the viewport; for relative it is the element's own original position. For example, left:50% places the element's left edge at half the containing block's width, often combined with transform:translateX(-50%) for horizontal centering.
QHow do I center horizontally with left:50%?
ASet the element to position:absolute, with the parent position:relative, use left:50% so its left edge lands at the container's midpoint, then apply transform:translateX(-50%) to shift it left by half its own width; that is the classic horizontal-centering trick. A cleaner modern alternative is the flex parent with display:flex; justify-content:center, which avoids the magic numbers entirely. The same translateX trick works with right:50% for centering from the right edge.
QWhy isn't left working?
AThe most common reason is that position is still static, since left only works on positioned elements. Next, if both width and right are set, left wins over right in LTR text; if you expected right to apply, remove left or width. Finally, confirm the value is valid, that is, auto, length, or percentage. Check the position and conflicting properties step by step.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏