HTML dirAttribute

HTML 全局属性HTML Global Attributes

Examples

A paragraph with text direction from right to left:

<bdo dir="rtl">Text direction from right to left!</bdo>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the dir attribute


Definition and Usage

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


Differences between HTML 4.01 and HTML5

In HTML5, the dir attribute can be used on any HTML element (it will validate on any HTML element, but is not necessarily useful).

In HTML 4.01, the dir attribute cannot be used on: <base>, <br>, <frame>, <frameset>, <hr>, <iframe>, <param>, and <script>.


Syntax

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

Attribute Values

Value Description
ltr Default. Text direction from left to right.
rtl Text direction from right to left.
auto Let the browser decide the text direction based on the content. Recommended only when the text direction is unknown.


HTML 全局属性HTML Global Attributes

Other Extensions