The HTML <dir> tag is used to make a list of directory titles. It is not supported in HTML4 as in HTML5 <ul> or CSS are used instead of <dir> tag.
Note: The <dir> tag is deprecated & no longer supported in HTML5
HTML
<!DOCTYPE html>
<html>
<body>
<p>List of all computer science subjects:</p>
<dir>
<li>Operating system</li>
<li>Data Structures</li>
<li>Computer network</li>
<li>DBMS</li>
<li>OOPs</li>
</dir>
</body>
</html>
Syntax
<dir>
<li></li>
<li></li>
</dir>
Values
Values
| Descriptions
|
ltr
| Used for languages that read from left to right, like English.
|
rtl
| Used for languages that read from right to left, such as Arabic.
|
auto
| Let the browser decide the text direction based on the content’s characters, applying the dominant direction to the whole element.
|
Alternative of dir Tag
The <ul> tag is perfect for unordered lists where the sequence of items doesn’t matter. It’s widely used in navigation menus, bullet-point lists, and more.
HTML
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Mouse</li>
<li>Keyboard</li>
<li>Speaker</li>
<li>Monitor</li>
</ul>
</body>
</html>
HTML <dir> tag – FAQs
What replaced the <dir> tag in HTML?
The functionality of the <dir> tag can be achieved using the <ul> (unordered list) or <ol> (ordered list) tags in modern HTML.
Can I still use the <dir> tag in HTML5?
Technically, you can use the <dir> tag, but it is considered obsolete, and its use is discouraged. It’s better to use <ul> or <ol> for lists.
How did the <dir> tag differ from the <ul> tag?
The <dir> tag was specifically intended for directory listings, whereas the <ul> tag is more general and can be used for any unordered list.
What attributes did the <dir> tag support?
The <dir> tag supported global HTML attributes and some specific ones like compact, which indicated that the list should be rendered in a compact style (which is also obsolete).
Why was the <dir> tag deprecated?
The <dir> tag was deprecated because its purpose was too specific and was better handled by more versatile elements like <ul> and <ol> that fit modern HTML standards.