Skip to: content, navigation

by Ian Lloyd

dir (HTML element)

Spec
Depr. Empty Version
Yes No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
<dir compact="compact">
</dir>

Example

The listing below shows a directory of plants:

<dir>
<li>shrubs</li>
<li>conifers</li>
<li>hedges</li>
</dir>
Type
block-level element
Contains
li elements only
Contained by
applet, blockquote, body, button, center, dd, del, div, fieldset, form, iframe, ins, li, map, noframes, noscript, object, td, th

Description

The dir element was originally intended to be used specifically to display directory lists, rather than to act as a generic list in which any content could be placed. Like the ol and ul list types, the dir element contains a series of li items.

Note that although the li is a block-level element, which would normally be able to contain other block-level elements, when it’s used in the context of a dir, a child li element can only contain inline elements.

Use This for…

The dir element is used for series of directory titles.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

When the dir element is used, most browsers will simply render the list exactly as they would a ul and series of li elements. As such, you’re better simply to use those elements instead, and thus ensure forwards and backwards compatibility, cross-browser support, and validity.

In this Section

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters