HTML - <dir> Tag



The HTML <dir> tag is used to specify a directory list, similar to the <ul> tag.

The HTML <dir> tag is deprecated and not supported in HTML5. Instead, use the tag, we can use the <ul> tag and CSS properties.

Syntax

Following is the syntax of the <dir> tag −

<dir> Lists... </dir>

Attributes

The HTML <dir> tag supports Global and Event attributes of HTML. Accepts some specific attributes, which are listed below.

Attribute Value Description
compact compact Specifies a compact rendering(Deprecated).
dir ltr
rtl
auto
Specifies the direction of the directory list(Deprecated).

Example: Creating Compact Directory List

The example below illustrates the usage of the <dir> tag, showing where, when, and how to use it to create a directory list. In the following example, we use the <dir> tag to create a compact directory list. Note that the compact attribute is deprecated and will not affect the display −

<!DOCTYPE html>
<html>

<head>
   <title>HTML dir Tag</title>
</head>

<body>
   <dir compact>
      <li>HTML</li>
      <li>CSS</li>
      <li>JS</li>
   </dir>
</body>

</html>

Example: Compact Directed Directory List

In the following example, we will use the <dir> tag to create a directed directory list. This HTML example demonstrates the <dir> tag with different text directions: left-to-right, right-to-left, and automatica direction detection −

<!DOCTYPE html>
<html>

<head>
    <title>HTML dir Tag</title>
</head>

<body>
    <dir dir="ltr">
        <li>HTML: HyperText Markup Language</li>
    </dir>
    <dir dir="rtl">
        <li>CSS: CAscading Style Sheet</li>
    </dir>
    <dir dir="auto">
        <li>JS: JavaScript</li>
    </dir>
</body>

</html>

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
dir Yes 1.0 Yes 12 Yes 1.0 Yes 4.0 Yes 12.1
html_tags_reference.htm
Advertisements