Прескочи на главни садржај
← 🎨 CSS as a design system·Модул B6 · Лекција 10
ЗадатакBuild a page that demonstrates dir='rtl' working. <html dir='rtl'> (set via JS for the demo), .card with margin-inline 16px, padding-inline 20px, padding-block 12px, background #f5f5f5. Add JS to set document.documentElement.dir = 'rtl' on load.

РТЛ подршка: дир='ртл' + минимални ЦСС

75 XP6 min
Теорија

When CSS uses logical properties, the HTML does the rest

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

That dir="rtl" attribute on <html> flips the document direction. If your CSS uses logical properties throughout, the whole UI mirrors:

  • Sidebar that was on the left → moves to the right.
  • Margins / padding flip.
  • Text alignment defaults flip.
  • Flex/grid directions flip naturally.

Per-element direction

<p dir="rtl">عربي</p>
<p dir="ltr">English mixed inside RTL page</p>

dir="auto" lets the browser infer from the first strong-direction character — useful for user-generated content of unknown language.

Things that DON'T auto-flip

  • Icons with directional meaning (back arrow, send arrow). Manually mirror them in RTL:
[dir="rtl"] .icon-back { transform: scaleX(-1); }
  • Position-based layouts using physical left / right instead of inset-inline-start / -end.
  • Numbers and dates — Arabic / Hebrew use latin numerals usually; verify locally.

Test with bookmarklet

javascript:document.documentElement.dir = document.documentElement.dir === 'rtl' ? 'ltr' : 'rtl';

Paste into the URL bar on any page; toggles direction instantly. If your layout breaks, you've still got physical properties somewhere.

CodeMentor i18n + RTL

CodeMentor supports 18 languages but none currently RTL (Arabic, Hebrew). When we add them, this is the playbook.

🔒

Региструј се да почнеш са кодом

Теорија је отворена за све. Едитор, преглед уживо и провера се откључавају са 7-дневним бесплатним пробним периодом — потребна картица.

Регистрација — бесплатан пробни период →

Првих 10 лекција у сваком путу су бесплатне. Без картице.

← ПретходнаСледећа лекција →

Један савет за Python или веб дневно — на имејл

Кратко, ручно писано, без спама. Одјава у једном клику.