HTML: The Definitive Guide

Previous Chapter 7 Next
 

7.5 Directory Lists

The directory list is a specialized form of the unordered list. [<ul>, 7.1.1]

The <dir> Tag

The designers of HTML originally dedicated the <dir> tag for displaying lists of files. As such, the browser, if it treats <dir> and <ul> differently at all (most don't), expects the various list elements to be quite short, possibly no longer than 20 characters or so. Some browsers display the elements in a multicolumn format and may not use a leading bullet.

Like the unordered list, directory list items are defined with the <li> tag. When used within a directory list, however, the <li> tag may not contain any block element, including paragraphs, other lists, preformatted text, or forms.

The following example puts the directory tag to its traditional task of presenting a list of filenames:

The distribution tape has the following files on it:
<dir>
  <li><code>README</code>
  <li><code>Makefile</code>
  <li><code>main.c</code>
  <li><code>config.h</code>
  <li><code>util.c</code>
</dir>

Notice we use the <code> tag to ensure that the filenames would be rendered in an appropriate manner (see Figure 7-9).

Like the other formatting tags we've seen so far, the <dir> tag has an optional compact attribute for producing an even more reduced list display, even though virtually none of the browsers is either willing or capable of compacting directory lists.

You can change the style Netscape uses to bullet the <dir> list items with the type attribute extension and the values circle, square, or disc. This behavior is identical to the usage of the type attribute in an unordered list.


Previous Home Next
Nesting Lists Book Index Menu Lists