HTML dir attribute

dir attribute decides the direction of text either from left to right or from right to left.

<p>The direction of this paragraph is from right to left.</p>
<p><bdo dir="rtl">This paragraph is in the reverse direction.</bdo></p>
</>

The direction of this paragraph is from right to left.

This paragraph is in the reverse direction.

Attribute values

All possible values of dir attribute

dir='rtl'

The direction is from right to left. By default, the Arabic language is from right to left.

<p>The direction of this paragraph is from right to left.</p>
<p><bdo dir="rtl">This paragraph is in the reverse direction.</bdo></p>
Try</>

dir='ltr'

The direction is from left to right. By default, the English language is from left to right.

dir='auto'

It is usually used where the direction of the text is truly unknown. The text sets its direction by bidirectional algorithm.

Related Tags

The tags that support dir attribute

This attribute can be applied to all html elements.

Specifically, this attribute can be applied on the <bdo> element.

If Arabic is written inside English language then the Arabic inherits its direction from the English language. As a result complexity may arise. In this case, <bdi> is more appropriate.



Was this article helpful?