HTML - <dir> Tag



HTML <dir> tag is used for specifying a directory list. This is very similar to <ul> tag.

HTML <dir> tag is no longer recommended as it is deprecated and not supported in HTML5. Instead of using this tag, we can use the <ul> tag and CSS properties.

Syntax

<dir> Lists... </dir>

Attribute

HTML dir tag supports Global and Event attributes of HTML. Accepts some specific attributes as well 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).

Examples of HTML dir Tag

Bellow examples will illustrate the usage of dir tag. Where, when and how to use dir tag to create directory list.

Create Compact directory List

In the following example, we are going to use the dir tag to create a compact directory list. No difference will be visible of using compact attribute as it is deprecated.

<!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>

Create Compact directed directory List

In the following example, we are going to use the dir tag to create a directed directory list.

<!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