The HTML dir tag refers to the use of the dir attribute in HTML, which defines the text direction of content. While older HTML specs mentioned a <dir> element (now obsolete), modern HTML relies on the dir attribute applied to standard elements like <html>, <p>, <div>, and <span>.Tag HTML meaning:
dir="ltr" → Left-to-right text direction
dir="rtl" → Right-to-left text direction
dir="auto" → Browser detects direction automatically
This attribute ensures content is displayed correctly for global audiences.
HTML Directory Tag vs HTML dir Tag (Clarification)
Many developers search for HTML directory tag, but it’s important to clarify:
The old <dir>HTML directory tag was used to represent directory lists.
It is deprecated and should not be used.
Modern best practice is to use semantic lists (<ul>, <ol>) and the dir attribute for direction control.
So today, when we say HTML dir tag, we mean the direction attribute, not the obsolete element.
HTML Tag dir Attribute Explained
The HTML tag dir attribute is used to specify the base direction of text.
Syntax
<p dir="ltr">This text flows from left to right.</p><p dir="rtl"></p>
Accepted Values
Value
Meaning
ltr
Left-to-right (default for English)
rtl
Right-to-left (Arabic, Hebrew)
auto
Browser decides based on content
Using the correct direction prevents broken layouts and misaligned UI components.
HTML Tag dir LTR: When to Use It
The HTML tag dir LTR is the default direction for most Western languages such as English, French, and German.
Example
<div dir="ltr"> <h1>Welcome to Our Website</h1> <p>This content reads normally from left to right.</p></div>You typically don’t need to specify ltr unless:
You’re overriding an inherited rtl
You’re mixing languages on the same page
HTML dir Tag Example (RTL Languages)
When working with Arabic, Hebrew, Persian, or Urdu, using dir="rtl" is critical.