Baseline Widely available
The HTMLElement.dir
property indicates the text writing directionality of the content of the current element. It reflects the element's dir
attribute.
Note that if the dir
attribute is unspecified, the element itself may still inherit directionality from its parent. However, that inherited directionality is not reflected by this property's value.
The text writing directionality of an element is which direction that text goes (for support of different language systems). Arabic languages and Hebrew are typical languages using the RTL directionality.
ValueOne of the following:
"ltr"
Left-to-right writing direction.
"rtl"
Right-to-left writing direction.
"auto"
The direction of the element must be determined based on the contents of the element.
""
The default value; the directionality is inherited from the parent element.
const para = document.getElementById("para1");
para.dir = "rtl";
// change the text direction on a paragraph identified as "para1"
Specifications Browser compatibility See also
document.dir
dir
global attributedirection
property:dir
pseudo-classRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3