This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
The Document.dir property is a string representing the directionality of the text of the document, whether left to right (default) or right to left. Possible values are 'rtl', right to left, and 'ltr', left to right.
A string.
| Specification |
|---|
| HTML> # dom-document-dir> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
dir |
36 | 12 | 1Incorrect behavior before Firefox 23. |
51 | 10.1 | 36 | 4Incorrect behavior before Firefox for Android 23. |
47 | 10.3 | 3.0 | 37 | 10.3 |
dir global attribute
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/dir