Description
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.
The below table summarizes its usage.
| Usage Details | |
| Placement | It is displayed as a Block element. |
| Contents | It can contain one or more <li> elements, which can only contain inline elements. |
| Tags | Both the opening and closing tags are required. |
| Versions | HTML 2, 3.2, 4, 4.01 This element is deprecated in HTML 4.01 and obsolete since HTML5, so avoid using this element in your markup. Instead, use the HTML List elements. |
Syntax
Here is the basic syntax of the <dir> element.
<dir>...</dir>
Examples
<!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>
Attributes
The following table shows the list of supported and unsupported attributes for the <dir> element.
| Attribute Type | Details |
| Element-Specific Attributes | The tag <dir> has some element-specific attributes listed in the below table. |
| Global Attributes | Like all other HTML tags, the tag <dir> supports the HTML Global Attributes. |
| Event Attributes | The tag <dir> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <dir> element.
| Attribute | Value | Required | Description |
compact |
compact | No | Obsolete Boolean attribute that specifies whether the list should be rendered in a compact style or not. |
Browser Compatibility
The tag <dir> is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 2+
- Firefox 1+
- Apple Safari 1+
- Opera 2.1+