HTML dir Global Attribute

Description

The global attribute dir defines the direction of the text of the content of the element.

Syntax

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

Values

  • ltrDetermines the direction of text from left to right. This is the default value.
  • rtlDetermines the direction of the text from right to left.
  • autoThe direction of the test is determined automatically by the browser based on the content (recommended only if the direction of the text is unknown).

Example

<body> 
   <p dir="ltr">This text will be displayed from left to right.</p> 
   <p dir="rtl">This text will be displayed from right to left. </p> 
   <p dir="auto">The direction of the test is determined automatically by the browser.</p> 
</body>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYesYesYesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYesYesYesYesYes