CSS left Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Positioning

What You’ll Learn

The left property controls how far an element sits from the left edge of its containing block. It is one of the core CSS positioning tools used with position: absolute, relative, fixed, and sticky.

01

Horizontal Offset

Move elements left or right.

02

Syntax

Length, percentage, auto.

03

Position Pair

Works with position values.

04

Containing Block

Know your reference box.

05

Percentages

Relative to container width.

06

Logical Alt

inset-inline-start for RTL.

Definition and Usage

The left CSS property sets the horizontal offset of a positioned element. It defines the distance between the left edge of the element’s margin box and the left edge of its containing block.

This property moves an element to the right when you use a positive value, or further left when you use a negative value. It is commonly used with position values such as absolute, relative, fixed, and sticky.

💡
Beginner Tip

Always set a non-static position before using left. Without it, the property has no visible effect on layout.

📝 Syntax

The syntax for the left property is straightforward:

syntax.css
selector {
  left: value;
}

Basic Example

left.css
.box {
  position: absolute;
  left: 50px;
}

Syntax Rules

  • The value can be a length, a percentage, or the keyword auto.
  • Positive values push the element away from the left edge.
  • Negative values can move the element partially outside the container.
  • The property is not inherited.
  • It only applies when position is not static.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toPositioned elements (relative, absolute, fixed, sticky)
InheritedNo
AnimatableYes, as a length or percentage
Common useAbsolute layouts, overlays, sidebars, and nudged relative elements

💎 Property Values

The default value of left is auto. That means the browser calculates placement based on normal layout rules and other positioning properties.

ValueExampleMeaning
Lengthleft: 20px;Fixed distance from the left edge in px, em, rem, etc.
Percentageleft: 50%;Distance as a percentage of the containing block’s width
autoleft: auto;Lets the browser determine the offset (default behavior)
inheritleft: inherit;Inherits the value from the parent element
initialleft: initial;Resets the property to its initial value (auto)
left: 50px; left: 50%; left: 1rem; left: auto;

Requires Positioned Elements

left controls horizontal offset from the containing block’s left edge. It works with these position values:

  • position: absolute — offsets relative to the nearest positioned ancestor.
  • position: fixed — offsets relative to the viewport.
  • position: sticky — offsets apply when the element becomes stuck.
  • position: relative — shifts the element from where it would normally appear.
🛠
Logical Alternative

For international layouts, consider inset-inline-start. In horizontal LTR pages it behaves like left, but it adapts in RTL writing mode.

👀 Live Preview

An absolutely positioned box with left: 50px inside a dashed container:

Examples Gallery

Position a box with pixel and percentage values, nudge a relatively positioned element, and pin fixed UI to the viewport.

🔢 Absolute Positioning

Start with the reference example — place a box 50 pixels from the left edge of its container.

Example 1 — Absolute left: 50px

Position a box 50 pixels from the left edge of a relatively positioned container.

left-absolute.html
<style>
  .container {
    position: relative;
    width: 300px;
    height: 200px;
    background-color: #f0f0f0;
  }
  .box {
    position: absolute;
    left: 50px;
    width: 100px;
    height: 100px;
    background-color: #4caf50;
  }
</style>

<div class="container">
  <div class="box"></div>
</div>
Try It Yourself

How It Works

The .box element is absolutely positioned 50 pixels from the left edge of the .container, which acts as the containing block because it has position: relative.

Example 2 — Percentage Offset

Use a percentage to place an element halfway across its container.

left-percent.css
.marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
Try It Yourself

How It Works

left: 50% moves the element’s left edge to the middle of the container. Pairing it with transform: translateX(-50%) centers the element itself.

📈 Relative & Fixed UI

Nudge elements in normal flow and pin fixed panels to the viewport edge.

Example 3 — Relative Position Nudge

Shift an element slightly to the right without removing it from document flow.

left-relative.css
.callout {
  position: relative;
  left: 20px;
}
Try It Yourself

How It Works

With position: relative, the element keeps its original space in the layout but is visually offset by 20 pixels.

Example 4 — Fixed Sidebar Panel

Pin a panel to the left side of the viewport with position: fixed.

left-fixed.css
.sidebar {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: 10rem;
}
Try It Yourself

How It Works

left: 1rem with position: fixed keeps the sidebar anchored to the viewport’s left edge as the user scrolls.

♿ Accessibility

  • Do not hide essential content — Fixed or absolutely positioned elements can cover links and buttons.
  • Support zoom and small screens — Test left values on narrow viewports.
  • Keep logical tab order — Visual offset with left does not change DOM reading order.
  • Prefer logical properties for RTL — Use inset-inline-start when building multilingual layouts.
  • Avoid horizontal-only layouts — Ensure content remains reachable without sideways scrolling.

🧠 How left Works

1

Element is positioned

Set position to absolute, fixed, sticky, or relative.

Position
2

left sets horizontal offset

The browser measures distance from the containing block’s left edge to the element’s margin edge.

CSS rule
3

Browser places the box

The element is drawn at the calculated horizontal position inside its containing block or viewport.

Layout
=

Precise horizontal placement

Sidebars, badges, overlays, and nudged elements land exactly where you need them.

🖥 Browser Compatibility

The left property is widely supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It has been part of CSS since early positioning specifications.

Universal · All browsers

Core positioning in every browser

left is a foundational CSS property. You can rely on it in any web project without polyfills.

99% Global browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Legacy & Chromium
Full support
Opera All versions · Modern & legacy
Full support
left property 99% supported

Bottom line: Safe to use everywhere. Still test your layout in the browsers your audience uses for consistent visual results.

🎉 Conclusion

The left property is a fundamental tool in CSS for positioning elements horizontally within their containers. It offers flexibility in design and can be used to create a wide variety of layouts, from simple nudges to fixed sidebars and centered overlays.

Whether you’re building a simple static webpage or a complex dynamic interface, understanding how to use left effectively will be valuable in your CSS toolkit. Experiment with different values and positioning contexts to see how this property helps you achieve your design goals.

💡 Best Practices

✅ Do

  • Set a non-static position before using left
  • Pair absolute children with a relative parent
  • Use percentages for responsive horizontal placement
  • Combine with top, right, or bottom for full control
  • Consider inset-inline-start for RTL-friendly layouts

❌ Don’t

  • Apply left without setting position
  • Confuse left with margin-left or padding-left
  • Cover important controls with fixed overlays
  • Forget containing block context for absolute elements
  • Hard-code physical left values when logical properties fit better

Key Takeaways

Knowledge Unlocked

Five things to remember about left

Use these points when positioning elements with CSS.

5
Core concepts
auto 02

Default auto

Browser decides.

Default
% 03

Percentages

Of container width.

Values
abs 04

Positioned

Required.

Pattern
RTL 05

Logical alt

inset-inline-start.

i18n

❓ Frequently Asked Questions

The left property sets the horizontal offset of a positioned element from the left edge of its containing block.
The default value is auto, which lets the browser determine placement based on other positioning rules and normal document flow.
No. left only affects elements with position set to relative, absolute, fixed, or sticky.
Yes. A percentage is calculated relative to the width of the containing block. For example, left: 50% moves the element halfway across its container.
In horizontal LTR writing mode they often match, but inset-inline-start is a logical property that adapts when text direction changes. left always refers to the physical left edge.

Practice in the Live Editor

Open the HTML editor, try left with absolute and fixed positioning, and build your own layout.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful