HTML | <dir> Tag

It is used to make a list of directory titles. It is not supported in HTML 5 <ul> or CSS are used instead of <dir> tag.

Syntax:

<dir> Lists... </dir>

Below example illustrates the <dir> tag in HTML:

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>dir tag</title>
        <style>
            .gfg {
                font-size:40px;
                font-weight:bold;
                color:green;
            }
            .geeks {
                font-size:25px;
                font-weight:bold;
            }
        </style>
    </head>
    <body>
        <div class = "gfg">GeeksforGeeks</div>
        <div class = "geeks"><dir> Tag</div>
        <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>                    

chevron_right


Output:

Optional Attributes: This tag contains single attributes Compact which is optional. It is used to specify the list size render smaller than normal by reducing the space between list items. It is a boolean attribute.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>dir tag</title>
        <style>
            .gfg {
                font-size:40px;
                font-weight:bold;
                color:green;
            }
            .geeks {
                font-size:25px;
                font-weight:bold;
            }
        </style>
    </head>
    <body>
        <div class = "gfg">GeeksforGeeks</div>
        <div class = "geeks"><dir> Tag</div>
        <p>List of all computer science subjects:</p>
            <dir compact>
                <li>Operating system</li>
                <li>Data Structures</li>
                <li>computer network</li>
                <li>Dbms</li>
                <li>Oops</li>
            </dir>
    </body>
</html>                    

chevron_right


Output:

Note: The compact attribute is not supported by any browser.

Supported Browsers: The browser supported by <dir> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.