Path // www.yourhtmlsource.comReference → <dir>

<dir>


Deprecated: The <dir> element is deprecated in HTML 4.01 and obsolete in HTML5. Use <ul> instead for all unordered lists.

The <dir> element was originally intended to create a directory list, displaying items in a multicolumn format similar to a file directory listing. However, this element has been deprecated because browsers never consistently implemented its intended behavior, and it provided no semantic advantage over the standard unordered list element.

Clock This page was last updated on 2025-11-27



Syntax (Deprecated)

<dir>
  <li>file1.txt</li>
  <li>file2.txt</li>
  <li>file3.txt</li>
</dir>

Attributes

  • compact - Requested compact rendering (deprecated, non-conforming)
  • class - CSS class name for styling (global attribute, still valid)
  • id - Unique identifier for the element (global attribute, still valid)
  • style - Inline CSS styles (global attribute, still valid)
  • title - Advisory information (global attribute, still valid)

The <dir> element itself is obsolete and should be replaced with <ul>. However, global attributes like id, class, and style remain conforming and can still be used. Only the compact attribute is deprecated.

Modern Replacement

Use <ul> instead:

<ul>
  <li>file1.txt</li>
  <li>file2.txt</li>
  <li>file3.txt</li>
</ul>

For multicolumn display, use CSS:

<ul style="column-count: 3;">
  <li>file1.txt</li>
  <li>file2.txt</li>
  <li>file3.txt</li>
  <li>file4.txt</li>
  <li>file5.txt</li>
  <li>file6.txt</li>
</ul>

When to Use

Do not use <dir>. This element is obsolete and should not appear in modern HTML documents. Any existing code using <dir> should be updated to use <ul> instead. Most browsers will render <dir> identically to <ul>, but this behavior is not guaranteed and the element may be removed from browser support entirely in the future.

If you encounter <dir> in legacy code, replace it with <ul> and use CSS for any special layout requirements such as multicolumn displays or horizontal lists. This ensures forward compatibility and valid HTML5 markup.

  • <ul> - Unordered list (recommended replacement)
  • <li> - List item
  • <ol> - Ordered list
  • <menu> - Menu list