Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon
Lists are powerful tools for grouping 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:
  • : Holds the list definitions (dl = definition list)

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

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

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

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

  1. First term name

  • Content for the definition of the first item

  • Second term name

  • Content for the definition of the second item

  • 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.

    About This Article

    This article is from the book:

    About the book authors:

    Ed Tittel is a 30-year veteran of the technology industry with more than 140 computing books to his credit, including the bestselling HTML For Dummies.

    Chris Minnick runs Minnick Web Services. He teaches, speaks, and consults on web-related topics and has contributed to numerous books, including WebKit For Dummies.

    This article can be found in the category: