Latest web development tutorials

HTML dir attribute

HTML Global Attributes HTML Global Attributes

Examples

Text direction is right-to-left paragraph:

<P dir = "rtl"> text direction from right to left! </ P>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the dir attribute


Definition and Usage

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


Differences between HTML 4.01 and HTML5

In HTML5, dir attribute can be used with any HTML element (it will verify that any HTML element, but not necessarily useful).

In HTML 4.01, dir element can not be used: <base>, <br>, <frame>, <frameset>, <hr>, <iframe>, <param>, and <script>.


grammar

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

Property Value

value description
ltr default. Text direction from left to right.
rtl Text direction from right to left.
auto Let the browser based on content to determine the direction of the text. Use only recommended when the text direction is unknown.


HTML Global Attributes HTML Global Attributes