The dir global attribute is an enumerated attribute indicates the directionality of the element's text. It can have the following values:
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 |
---|---|---|
WHATWG HTML Living Standard The definition of 'dir' in that specification. | Living Standard | No change from latest snapshot, HTML5.1 |
HTML5.1 The definition of 'dir' in that specification. | Recommendation | Snapshot of WHATWG HTML Living Standard, no change from HTML5 |
HTML5 The definition of 'dir' in that specification. | Recommendation | Snapshot of WHATWG 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> . |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
HTMLElement.dir
that reflects this attribute.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir