# RTL

> The RTL (right-to-left) refers to languages written from right to left, such as Arabic and Hebrew.

## How do I support right-to-left languages?

The text direction of languages like Arabic, Hebrew and Persian. Supporting them means mirroring the layout, using the `dir` attribute and logical CSS properties, and handling mixed text where right-to-left and left-to-right parts meet.

- Topic: Internationalization
- Type: concept

## Example

Wrong:

```css
.card {
  margin-left: 16px;
  text-align: left;
}
```

Right:

```css
.card {
  margin-inline-start: 16px;
  text-align: start;
}
```

Logical properties follow the text direction, so the margin moves to the right side when `dir` is 'rtl'.

## Common mistakes

- Flipping the whole page with `transform` instead of using `dir`.

## Key points

- The `<html>` element has `dir="rtl"` for RTL locales.
- Styles use logical properties instead of `left` and `right`.
- User-generated text uses `dir="auto"` or `<bdi>`.

## Interview questions

### Does dir='rtl' mirror the layout automatically?

Partly. Text, flexbox and grid order follow it, but physical properties like `left` and `margin-right` stay where they are.

### Should icons be mirrored in right-to-left layouts?

Directional icons like back arrows should be mirrored. Icons without direction, such as search or a check mark, should stay as they are.

### How do I style an element only in RTL?

Use the `:dir(rtl)` pseudo-class or an `[dir='rtl']` attribute selector on the element or its ancestor.

## Related cards

- [\[dir\]](https://wonderium.dev/html/dir.md)
- [Logical Properties](https://wonderium.dev/css/logical-properties.md)
- [`<bdi>`](https://wonderium.dev/html/bdi.md)
- [:dir()](https://wonderium.dev/css/dir.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/rtl
- Last updated: 2026-11-25
