HTML global attribute dir








The dir attribute specifies the direction of an element's text.

The two supported values are ltr for left-to-right text and rtl for right-to-left text.

Syntax

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

Attribute Values

ltr
Default. Left-to-right text direction
rtl
Right-to-left text direction
auto
Browser to decide

Browser compatibility

dir Yes Yes Yes Yes Yes




Example

The following code shows how to use dir attribute.

<!DOCTYPE HTML>
<html>
<body>
<p dir="rtl">This is right-to-left</p>
<p dir="ltr">This is left-to-right</p>
</body>
</html>

Click to view the demo