<dir>

The HTML <dir> element, which is now obsolete, was intended for creating a directory list of items with specific styling. CSS is recommended for this purpose now.

dir Tag

The <dir> tag was historically used to create a list of directory-style items, with each entry represented by the <li> tag. It functioned similarly to the <ol> and <ul> elements. By default, items were displayed with bullet points.

Example

  • HTML
  • XHTML
  • CSS
index.html
<ul>
  <li>HTML</li>
  <li>XHTML</li>
  <li>CSS</li>
</ul>
  • Adjusting line height in a list using CSS:
  • HTML
  • XHTML
  • CSS
index.html
<ul style="line-height:80%">
  <li>HTML</li>
  <li>XHTML</li>
  <li>CSS</li>
</ul>

DOM Interface

The <dir> element was associated with the HTMLDirectoryElement interface before being deprecated.

Attributes

This element supports global attributes, which are available to all HTML elements.

Conclusion

The <dir> tag was once used for listing directory-style items, but it is now obsolete in favor of more modern list elements like <ul>. For styling and structuring unordered content, <ul> with appropriate CSS is the recommended approach.