HTML <dir> Tag

Not Supported in HTML5

Example

A directory list:

<dir>
<li>html</li>
<li>xhtml</li>
<li>css</li>
</dir>

Try it Yourself »


Definition and Usage

The <dir> tag is not supported in HTML5. Use <ul> or CSS instead.

The <dir> tag is used to list directory titles.


Browser Support

Element
<dir> Yes Yes Yes Yes Yes

Tips and Notes

Tip: Use CSS to style lists! In our CSS tutorial you can find more details about styling lists.


Differences Between HTML 4.01 and HTML5

The <dir> tag is not supported in HTML5.


Optional Attributes

Attribute Value Description
compact compact Not supported in HTML5.
Specifies that the list should render smaller than normal

HTML <dir> compact Attribute

Example

Use of the compact attribute in a directory list:

<dir compact>
<li>html</li>
<li>xhtml</li>
<li>css</li>
</dir>

Try it Yourself »


Definition and Usage

The compact attribute is a boolean attribute.

When present, it specifies that the list should render smaller than normal, by reducing the space between lines and the indentation of the list.


Browser Support

Attribute
compact Not supported Not supported Not supported Not supported Not supported

Compatibility Notes

The compact attribute of <dir> is not supported in HTML5. Use CSS instead.

CSS syntax: <dir style=”line-height: 80%”>

CSS Example: Reduce line-height in a list

In our CSS tutorial you can find more details about the line-height property.


Differences Between HTML and XHTML

In XHTML, attribute minimization is forbidden, and the compact attribute must be defined as <dir compact=”compact”>.


Syntax

<dir compact>

Post Author: Zahid Farid