HTML | dir Attribute
This attribute is used to specify the text direction of the element content.
Syntax:
<element dir = "ltr|rtl|auto">
Attribute Value: This attribute contains three value which are listed below:
- ltr: It is the default value. This value represent the text in Left-to-right text direction.
- rtl: This value represent the text in right-to-left text direction.
- auto: Let the browser figure out the text direction, based on the content.
Example 1:
<!DOCTYPE html> <html> <head> <title>dir atribute</title> <style> h1 { color:green; } h1, h2 { text-align:center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>dir attribute</h2> <p dir="rtl">GeeksforGeeks: A computer science portal for geeks</p> </body> </html> |
chevron_right
filter_none
Output:

Example 2:
<!DOCTYPE html> <html> <head> <title>dir atribute</title> <style> h1 { color:green; } h1, h2 { text-align:center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>dir attribute</h2> <p dir="ltr">GeeksforGeeks: A computer science portal for geeks</p> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by dir attribute are listed below:
- Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | low Attribute
- HTML | <img> alt Attribute
- HTML | <a> rel Attribute
- HTML | value Attribute
- HTML | for Attribute
- HTML | <img> src Attribute
- HTML | min Attribute
- HTML | <map> name Attribute
- HTML | <li> value Attribute
- HTML | title Attribute
- HTML | placeholder Attribute
- HTML | onmousedown Attribute
- HTML | multiple Attribute
- HTML | onblur Attribute
- HTML | oncut Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



