lang="ar" vs dir="rtl": What Each Attribute Does
Two attributes that solve two different problems โ and measured evidence of how often real websites confuse them.
Written alongside the author's own 220-site RTL adoption crawl, which measured exactly this confusion in production websites.
lang="ar" tells software what language the content is in โ screen readers, translators, spell-checkers. dir="rtl" tells the browser which direction to lay text out in. They're independent: a page can declare one without the other, and in a measured 220-site sample, 16% did exactly that โ declaring Arabic language while leaving direction undeclared.
1. Two Attributes, Two Completely Different Jobs
lang and dir are both HTML global attributes that commonly appear together on Arabic pages, which makes it easy to assume they're two ways of saying the same thing. They aren't.
- `lang` declares the language of the content. It tells screen readers which pronunciation rules to use, tells browsers which spell-checker dictionary to apply, tells translation tools what to translate from, and tells search engines what language to index the page under.
lang="ar"means "this content is Arabic" โ nothing about direction. - `dir` declares the base text direction for rendering.
dir="rtl"tells the browser to lay out block-level content right-to-left: where the scrollbar goes, which side text aligns to by default, which direction lists and tables flow. It says nothing about what language the content is in.
You can have Arabic content in an LTR-styled interface embedded in an English-first site (lang="ar" dir="ltr", unusual but valid), and you can have direction set to RTL for a page whose primary language isn't Arabic (some Persian, Urdu, and Hebrew sites, for instance). The two attributes are independent controls that usually โ but don't automatically โ point the same direction.
2. Why an Arabic Page Almost Always Needs Both
For a page whose primary content is Arabic, you need lang="ar" (or a more specific tag like lang="ar-SA") for language-dependent tooling to work correctly, and you need dir="rtl" for the layout to actually read right-to-left. Setting only one leaves a real gap:
- `lang="ar"` without `dir="rtl"`: Screen readers and translators correctly identify the content as Arabic, but the browser renders it in a left-to-right layout โ the scrollbar, alignment, and flow direction are all backwards for a native reader, even though the text itself renders correctly (Arabic script is directionally-aware at the character level regardless of the
dirattribute). - `dir="rtl"` without `lang` set to Arabic: The layout direction is correct, but assistive technology and language tooling don't know what language they're dealing with โ a screen reader may apply the wrong pronunciation rules, and automated translation tools may guess wrong.
Per the W3C's own guidance on language declarations, these are documented as separate, complementary declarations โ not a single combined setting.
3. How Often Real Websites Get This Wrong
In a 220-site, country-stratified crawl of ranked Arabic-region homepages with substantial Arabic content:
| Pattern | Sites | Share |
|---|---|---|
Declares Arabic lang without root dir="rtl" | 35 | 16% |
Sets root dir="rtl" without an Arabic lang value | 7 | 3% |
| Both declared correctly | 131 | 60% |
The "lang without dir" pattern (16%) is by far the more common of the two mismatches โ more than double the reverse case. That's a reasonable pattern to expect: language metadata is often set once, early, at the CMS or template level, while direction is sometimes handled โ or forgotten โ separately in the stylesheet or a later layout pass.
Full detection rules and the complete 220-site dataset are published on the [Arabic & RTL Web Adoption page](/arabic-web-stats/rtl-adoption).
Frequently Asked Questions
Does lang="ar" automatically make a page right-to-left?
No. lang="ar" only declares the content language for tools like screen readers, translators, and search engines โ it has no effect on layout direction. Layout direction is controlled entirely by the separate dir attribute, which needs dir="rtl" to lay the page out right-to-left.
Which is more commonly missing on Arabic websites: lang or dir?
In a measured 220-site sample, sites that declared Arabic lang without setting root dir="rtl" (16%) outnumbered the reverse case โ dir="rtl" without a recognized Arabic lang value (3%) โ by more than 5 to 1.