Global Attributes

HTML dir attribute

Sets base text direction independently of language. auto uses text direction detection; use rtl for known right-to-left content and ltr for known left-to-right content. Applicability: global HTML attribute, subject to element-specific restrictions and browser support.

Formal Syntax & Structure

html syntaxhtml
dir="rtl"

Parameters & Attributes

NameTypeDescription
direnumerated: ltr, rtl, autoSets base text direction independently of language. auto uses text direction detection; use rtl for known right-to-left content and ltr for known left-to-right content.

Working Example

Example Snippethtml
<p lang="fa" dir="rtl">سلام دنیا</p>

Browser Compatibility

Minimum supported versions across modern rendering engines

Chrome
1
Yes
Edge
≤15
Yes
Firefox
1
Yes
Safari
≤4
Yes
Checked desktop BCD snapshot: global dir attribute. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted. Not a separate version claim for dir=auto.
HTML Living Standard
HTML Reference