# left

> The `left` CSS property specifies the horizontal offset of a positioned element from the left edge of its containing block.

## How do I center an absolute element with left: 50%?

The property that sets the distance between the left edge of an element and the left edge of its containing block. With 'absolute' or 'fixed' `position` it places the element in its nearest positioned ancestor or the viewport, while with 'relative' it shifts it from its normal place.

- Topic: Positioning
- Type: property
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```css
.tooltip {
  position: absolute;
  left: 50%;
}
```

Right:

```css
.tooltip {
  position: absolute;
  left: 50%;
  translate: -50% 0;
}
```

`left: 50%` moves the left edge to the center; `translate` shifts it back by half its own width.

## Common mistakes

- `left: 50%` puts the element's left edge, not its center, in the middle.
- `left` is ignored because `position` is still 'static'.

## Key points

- `left: 50%` centering also shifts the element back with `translate: -50%` or `transform: translateX(-50%)`.
- Layouts that support right-to-left text use `inset-inline-start` instead of `left`.
- Elements using `left` have a `position` other than 'static'.

## Interview questions

### Does left: 50% center an element?

No. It moves the element's left edge to the middle; add a translate of '-50%' to center it.

### What happens if I set both left and right?

On absolute elements with 'auto' width, the element stretches between both; with a fixed width in left-to-right text, `left` wins.

### What is the logical version of left?

`inset-inline-start`, which maps to `right` in right-to-left text.

## Related cards

- [position](https://wonderium.dev/css/position.md)
- [right](https://wonderium.dev/css/right.md)
- [inset](https://wonderium.dev/css/inset-property.md)
- [translate](https://wonderium.dev/css/translate-property.md)
- [Logical Properties](https://wonderium.dev/css/logical-properties.md)

---

- Level: [CSS](https://wonderium.dev/css.md)
- HTML version: https://wonderium.dev/css/left
- Last updated: 2026-11-25
