The dir
global attribute is an enumerated attribute that indicates the directionality of the element's text.
The dir
global attribute is an enumerated attribute that 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.Note: This attribute is mandatory for the <bdo>
element where it has a different semantic meaning.
<bdi>
element. If not set, its value is auto
.direction
and unicode-bidi
, if a CSS page is active and the element supports these properties.auto
value should be used for data with an unknown directionality, like data coming from user input, eventually stored in a database.Note: Browsers might allow users to change the directionality of <input>
and <textarea>
s in order to assist with authoring content. Chrome and Safari provide a directionality option in the contextual menu of input fields while Legacy Edge uses the key combinations Ctrl + Left Shift and Ctrl + Right Shift. Firefox uses Ctrl/Cmd + Shift + X but does NOT update the dir
attribute value.
Specification |
---|
HTML Standard # the-dir-attribute |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
dir |
1 | 79 | 1 | No | 15 | ≤4 | 4.4 | 18 | 4 | 14 | ≤3.2 | 1.0 |
HTMLElement.dir
that reflects this attribute.
© 2005–2023 MDN 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