How to Create Definition Lists in HTML5

By Ed Tittel, Chris Minnick

Lists are powerful tools to group similar elements, and lists give visitors to your site an easy way to zoom in on groups of information. Just about anything fits in a list, from sets of instructions to collections of links. Definition lists group terms and definitions into a single list and require three elements to complete the list:

  • <dl>: Holds the list definitions (dl = definition list)

  • <dt>: Defines a term in the list (dt = definition term)

  • <dd>: Defines a definition for a term (dd = definition list definition)

You can have as many terms (defined by <dt>) in a list (<dl>) as you need. Each term can have one or more definitions (defined by <dd>).

Creating a definition list with two items requires tags and content in the following order:

  1. <dl>

  2. <dt>

  3. First term name

  4. </dt>

  5. <dd>

  6. Content for the definition of the first item

  7. </dd>

  8. <dt>

  9. Second term name

  10. </dt>

  11. <dd>

  12. Content for the definition of the second item

  13. </dd>

  14. </dl>

The following definition list includes three terms, one of which has two definitions:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Definition Lists</title>
  </head>
  <body>
    <h1>Markup Language Definitions</h1>
    <dl>
      <dt>SGML</dt>
        <dd>The Standard Generalized Markup Language</dd>
      <dt>HTML</dt>
         <dd>The Hypertext Markup Language</dd>
         <dd>The markup language you use to create web pages.</dd>
      <dt>XML</dt>
        <dd>The Extensible Markup Language</dd>
    </dl>
  </body>
</html>

The figure shows how a browser displays this HTML.

image0.jpg

If you think items in a list are too close together, you can use CSS styles to carefully control all aspects of list appearance.

Note that definition lists often display differently inside different browsers, and they aren’t always handled the same by search engines or text-to-speech translators. About.com has a nice discussion of definition lists on their Web Design / HTML page.

Alas, this means that definition lists may not be the best choice of formatting for lists you create (even lists of definitions). For a more detailed discussion, see the excellent coverage of this topic on Max Design.