Creating Definition Lists
Definition lists, also called glossary lists, are a special type of list in HTML. They provide a format like a dictionary entry, with an identifiable term and indented definition paragraph. This format is especially useful when listing items with extensive descriptions, such as catalog items or company departments. The- element provides both a beginning and ending line break. In the
- tag marks the term and the
- tag defines the paragraph. These are both open tags, meaning they don't require a closing tag to contain text.
- container, the
The standard format of a definition list is as follows:
The HTML 4.0 specification provides an important optional attribute for
- : COMPACT. This attribute is supposed to be interpreted as a list with a different style, presumably with a smaller font size or more compact character spacing. This could be useful for embedded definition lists (those inside other definition, numbered, or bulleted lists), or for graphic effect. Most browsers, however, ignore the attribute, displaying the definition list to the standard format.
Definition lists can include other HTML elements. The most common are physical and logical styles and other list containers. Although Web browsers can correctly interpret elements such as headings, this is bad HTML; their forced line breaks are not pretty and heading tags are usually meant to define relationships in paragraphs, not within lists. Listing 9.8 shows examples of how you can create definition lists.