Home

How to Create Definition Lists in HTML5

|
|  Updated:  
2022-08-11 20:10:42
HTML5 and CSS3 All-in-One For Dummies
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

  2. Content for the definition of the first item

  3. Second term name

  4. 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 author:

Ed Tittel is a 28-year veteran of the computer industry. A seasoned author and consultant, Ed has more than 140 books to his credit.

Chris Minnick is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the For Dummies series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.