Most RTL bugs come from CSS written for one direction. Set the direction in markup, write spacing as start and end instead of left and right, and isolate text you did not write. Here is what each rule does in a real browser.
Put lang="ar" and dir="rtl" on the html element of every Arabic page, not a CSS direction rule: the W3C recommends markup because direction is part of the content, not decoration. Then write your CSS with logical properties (margin-inline-start, padding-inline-end, inset-inline-start) and the same stylesheet lays out correctly in both languages.
Text you do not control, such as user names, product titles and phone numbers, needs isolation so it cannot reorder the sentence around it. Use <bdi> or dir="auto" for it, and dir="ltr" on inputs for phone numbers, card numbers and codes. Everything below was checked in Chrome 157 with a test page on 16 November 2026.
| In an RTL page | Logical version | |
|---|---|---|
| margin-left: 16px | Stays on the left (does not flip) | margin-inline-start: 16px |
| padding-right: 8px | Stays on the right | padding-inline-end: 8px |
| border-left: 4px solid | Stays on the left | border-inline-start: 4px solid |
| left: 0 (positioned) | Stays on the left | inset-inline-start: 0 |
| direction: rtl in CSS | Works visually, but the direction is lost if the CSS does not load | dir="rtl" on the html element |
| dir="ltr" on a phone field | Arabic digits with spaces (٠٩٣٣ ١٢٣ ٤٥٦) still show in reverse group order | dir="ltr" plus unicode-bidi: isolate-override |
This is the exact page our browser test loads and measures. Use it as a starting point, or open it with dir="ltr" to see the same CSS lay out for English.
<!doctype html>
<html lang="ar" dir="rtl">
<head>
<meta charset="utf-8">
<style>
.card { margin-inline-start: 16px; padding-inline-end: 8px; border-inline-start: 4px solid; }
.old { margin-left: 16px; } /* physical: stays on the left in RTL */
.badge { position: absolute; inset-inline-start: 0; top: 0; }
.wrap { position: relative; width: 400px; height: 40px; }
.tel { unicode-bidi: isolate-override; } /* keeps ٠٩٣٣ ١٢٣ ٤٥٦ in typed order */
</style>
</head>
<body style="margin:0; width:400px">
<div class="card" id="card">بطاقة</div>
<div class="old" id="old">بطاقة</div>
<div class="wrap" id="wrap"><span class="badge" id="badge">جديد</span></div>
<p dir="auto" id="auto">Hello مرحبا</p>
<input type="tel" dir="ltr" id="phone" value="+963 933 123 456">
<p><span dir="ltr" id="digits">٠٩٣٣ ١٢٣ ٤٥٦</span></p>
<p><span dir="ltr" class="tel" id="digits-fixed">٠٩٣٣ ١٢٣ ٤٥٦</span></p>
<p id="price">السعر: <bdi id="name">iPhone 13</bdi> فقط</p>
</body>
</html>
The test checks 13 things on this page in headless Chrome 157: the four logical properties above, that margin-left does not flip, that dir="auto" on "Hello مرحبا" resolves to LTR, that the tel input stays LTR, that <bdi> computes to unicode-bidi: isolate, and the Arabic-digit case below.
Push notifications, SMS, page titles and CSV exports have no dir attribute. Decide the direction from the first strong letter, the same rule the browser applies for dir="auto", and wrap inserted text in the Unicode isolate characters FSI and PDI:
// Mixed Arabic + English text: find a string's direction and isolate it so it
// cannot reorder the sentence around it (same rule the browser uses for dir="auto").
const RTL_CHAR = /[-ࣿיִ-﷿ﹰ-]/; // Hebrew, Arabic, Syriac, Thaana, presentation forms
const LTR_CHAR = /[A-Za-zÀ-ɏͰ-ϿЀ-ӿ]/;
function firstStrongDir(text) {
for (const ch of String(text)) {
if (RTL_CHAR.test(ch)) return "rtl";
if (LTR_CHAR.test(ch)) return "ltr";
}
return null; // only digits, spaces, punctuation: let the paragraph decide
}
// For plain-text places (SMS, push, notifications, <title>): wrap in FSI ... PDI.
const isolate = (text) => "" + text + "";
firstStrongDir("2026 آيفون"); // "rtl": digits are weak, the first letter decides
Tested with 6 cases: Arabic first, Latin first, digits before Arabic, a phone number on its own (no strong letter, returns null), an Arabic presentation form, and the isolate wrapper.
Use the dir attribute on the html element. The W3C advises markup because the direction belongs to the content, and it still applies if the stylesheet fails to load.
Behaviour measured in headless Chrome 157 on 16 November 2026. Logical properties are supported in all current major browsers; check the MDN compatibility tables if you support old devices.
We build bilingual sites and apps for Syrian businesses. Tell us what you have.