The dir
attribute in HTML
Sets the value of the directionality property
Directionality of text | |
---|---|
Property name: | directionality |
Attribute name: | dir |
Attribute type: | enumerated attribute |
Inherited: | Yes |
Make sure you understand the difference between an attribute and property and are familiar with the definitions of other HTML terms.
dir="ltr"
- left to right
dir="rtl"
- right to left
dir="auto"
- the direction is determined by the content of the element
The default value of the directionality property when the attribute is not coded on the top element is ltr
(left to right). On other elements where the attribute is not coded, the value of the dir property is inherited from the parent element.
The directionality can be overridden with the <bdo> tag (bi-directional override) or the <bdi> tag (bi-directional isolation).