HTML dir Attribute

HTML dir Attribute: The HTML dir attribute defines the text direction of the content of the element. This can be applied to all HTML elements.

HTML dir Attribute

Syntax: <element dir = “ltr|rtl|auto”>

Here, the attribute consists of three values. They are as follows:

  • ltr: It’s a default value and represents the text from left to the right direction.
  • rtl: It represents the text from right to left direction.
  • auto: It will describe the text direction based on content.

Browser Support

The HTML dir attribute is supported by the following browsers:

  • Chrome
  • Opera
  • Firefox
  • Internet Explorer

dir attribute Example:

<!DOCTYPE html>
<p dir="ltr">This is a text!</p>
<p dir="rtl">This is a text!</p>


HTML dir attribute