Our volunteers haven't translated this article into Srpski yet. Join us and help get the job done!
You can also read the article in English (US).

The dir global attribute is an enumerated attribute indicates the directionality of the element's text.

It can have the following values:

  • ltr, which means left to right and is to be used for languages that are written from the left to the right (like English);
  • rtl, which means right to left and is to be used for languages that are written from the right to the left (like Arabic);
  • auto, which lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. This keyword is not supported on IE/Edge browsers (see note below).

Note: According to Microsoft's open specifications, IE/Edge does not support the "auto" keyword on elements. With development of Edge on Chromium nearing completion, adding support on the existing version of Edge is highly unlikely.

Usage notes

This attribute is mandatory for the <bdo> element where it has a different semantic meaning.

  • This attribute is not inherited by the <bdi> element. If not set, its value is auto.

  • This attribute can be overridden by the CSS properties direction and unicode-bidi, if a CSS page is active and the element supports these properties.

  • As the directionality of the text is semantically related to its content and not to its presentation, it is recommended that web developers use this attribute instead of the related CSS properties when possible. That way, the text will display correctly even on a browser that doesn't support CSS or has the CSS deactivated.

  • The auto value should be used for data with an unknown directionality, like data coming from user input, eventually stored in a database.


Specification Status Comment
HTML Living Standard
The definition of 'dir' in that specification.
Living Standard No change from latest snapshot, HTML 5.1
HTML 5.1
The definition of 'dir' in that specification.
Recommendation Snapshot of HTML Living Standard, no change from HTML5
The definition of 'dir' in that specification.
Recommendation Snapshot of HTML Living Standard, from HTML 4.01 Specification it added the auto value, and is now a true global attribute.
HTML 4.01 Specification
The definition of 'dir' in that specification.
Recommendation Supported on all elements but <applet>, <base>, <basefont>, <bdo>, <br>, <frame>, <frameset>, <iframe>, <param>, and <script>.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
dirChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support  
Full support

See also

Document Tags and Contributors

Contributors to this page: monkeypox8, mdnwebdocs-bot, wbamberg, mfuji09, fscholz, xfq, mmmoussa, teoli
Last updated by: monkeypox8,