Blog / Development

RTL layout and Arabic typography for the web

Ramadan and Eid campaigns often need Arabic pages. Right-to-left layout is mostly solved by modern CSS, if you set it up correctly from the start.

By Abdullah NomanDecember 3, 20263 min read

Mosque, hairline isometric illustration

Short answer: set <html lang="ar" dir="rtl">, use CSS logical properties (margin-inline-start, padding-inline, inset-inline-end) instead of left and right, mirror directional icons but not everything, and use a font designed for Arabic.

1. Set direction on the document

<html lang="ar" dir="rtl">

Flexbox and grid follow the direction automatically: the first item appears on the right.

2. Use logical properties

.card { padding-inline: 24px; margin-inline-start: auto; border-inline-start: 2px solid var(--accent); }
.close { position: absolute; inset-inline-end: 16px; }
p { text-align: start; }

These work in both directions, so one stylesheet serves English and Arabic.

3. Mirror what has direction

  • Mirror: back and forward arrows, progress bars, sliders, breadcrumbs.
  • Do not mirror: logos, play buttons, clocks, checkmarks, charts with time on the x-axis (often kept left to right; check with your audience), and illustrations of real objects.
[dir="rtl"] .icon-arrow { transform: scaleX(-1); }

4. Arabic fonts

  • Use a font with real Arabic glyphs, such as Noto Sans Arabic, IBM Plex Sans Arabic or Cairo.
  • Arabic often needs a slightly larger size and line height than Latin text at the same visual weight.
  • Never add letter-spacing to Arabic: it breaks the joined letters.

5. Numbers and mixed text

  • Decide on Western (0–9) or Arabic-Indic digits based on your audience.
  • Mixed Arabic and English in one line can reorder strangely; wrap English fragments in <bdi> or use dir="auto" on user content.
Mosque, hairline isometric illustration
Illustrations of real objects stay unmirrored in RTL. Mosque dome and minaret

6. Test

  • Switch dir on a page and look for anything stuck to the wrong side.
  • Check forms: input text alignment, icons inside inputs, error messages.
  • Ask a native reader to review copy and layout before launch.

Questions

How do I make a website right to left?

Set lang="ar" dir="rtl" on the html element and use CSS logical properties instead of left and right.

Should icons be mirrored in RTL?

Directional icons such as arrows should be; logos, play buttons, clocks and illustrations of real objects should not.

What fonts are good for Arabic websites?

Fonts with proper Arabic glyphs, such as Noto Sans Arabic, IBM Plex Sans Arabic or Cairo.

Can I use letter-spacing with Arabic text?

No. It breaks the connections between Arabic letters.

Keep reading