Advertisement
Home Open Editor ❯

HTML dir Attribute

Example

<p dir="rtl">Hello world</p>

Try this code ❯

Meaning

The dir attribute specifies the text direction as related to the lang attribute.

The accepted values under the HTML 4.01 specification are ltr (left to right) and rtl (right to left).

It should be possible to override whatever direction a user agent sets by using this attribute with the <bdo> element


Standard Syntax

<element dir="auto|ltr|rtl">


Applies to:

The dir attribute can be used on the following element:

Element Attribute
All HTML elements dir

Advertisement

Attribute Values

Value Description
auto Browser defines text direction
ltr Default. Left-to-right text direction
rtl Right-to-left text direction
Home Open Editor ❯
Advertisement