HTML Element <dir> Example

The HTML element <dir> is used to specify a multicolumn directory list.

This element is not supported in HTML5 and you should avoid using it in the markup. Instead, use HTML list elements.

Here is an example that explains the element in action. Click the below link to see the live demo.

Run this on IDE

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Example - HTML Element dir</title>
</head>
<body>
    <!-- This element is obsolete and not valid in HTML5, so avoid using it in your markup -->
    <h2>Directory List</h2>
    <dir>
        <li>Item 1</li>
        <li>Item 2</li>
    </dir>
    <!-- Alternative and better way is to use unordered list element as shown below. -->
    <h2>Unordered List</h2>
    <ul>
        <li>Item 1</li>
        <li>Item 2</li>
    </ul>
</body>
</html>

Related Links