CHAPTER 15 · HTML

Description lists: connect names with their explanations

A glossary pairs a term with its meaning. A session summary pairs a label such as Room with its value. Use a description list when these name-and-description relationships matter more than bullets or a sequence.

Download example files (ZIP)

Start with a familiar example

Imagine a classmate asks what an editor is. You write the word editor and then explain, “An application where you write and change text.” The word and explanation belong together.

That relationship is different from a packing list, where every item is simply another thing to bring. It is also different from numbered instructions. HTML provides dl, a description list, for groups of names and descriptions.

Dl, dt and dd

ElementRoleExample content
dlContains the description listThe complete glossary
dtA name or term being describedEditor
ddA description, explanation or value for that nameAn application for writing and changing text

Dt does not have to be a dictionary word. In a session summary, Room can be a dt and Room 6 its dd. Dd does not mean another bullet item; it describes the preceding name or group of names.

HTML fragment — part of a document
<dl>
  <dt>Editor</dt>
  <dd>An application for writing and changing text.</dd>
  <dt>Browser</dt>
  <dd>An application that opens and displays web pages.</dd>
</dl>

Put dt and dd inside dl. Do not add li around them. Use ordinary text for a short name and clear sentences for an explanation. The browser often indents dd by default, but the indentation can change with CSS.

Complete program: practice-glossary.html

practice-glossary.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Small HTML Practice Glossary</title>
</head>
<body>
  <h1>Three words for your first page</h1>
  <dl>
    <dt>Editor</dt>
    <dd>An application where you write and change your HTML source.</dd>
    <dt>Browser</dt>
    <dd>An application that reads the page and displays its content.</dd>
    <dt>File</dt>
    <dd>A saved collection of information with a name and location.</dd>
  </dl>
</body>
</html>
Browser previewDocument title: Small HTML Practice Glossary

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

Expected result: each of the three names is followed by its explanation. There are no automatically numbered steps. The document title appears in the browser tab, and the main heading appears above the glossary.

More than one name or description

A description-list group can contain one or more dt elements followed by one or more dd elements. Consecutive names share the following description or descriptions.

For example, two common names for the same item can share one explanation. A single workshop can also have two separate descriptions: what to bring and what to complete. These are groups, not a rule that every second child must always be dd.

HTML fragment — part of a document
<dl>
  <dt>USB drive</dt>
  <dt>Pen drive</dt>
  <dd>A small portable device used to store and move files.</dd>
</dl>

Both names belong to the same group here. If you mean two different objects with different explanations, give each name its own description instead. Do not place an unrelated dt between a name and its intended dd.

Names first, descriptions next
  1. 1Open dl
  2. 2Write one or more dt names
  3. 3Follow with their dd descriptions
  4. 4Start the next group of names

Several names can share descriptions. Keep each group together.

Complete program: session-facts.html

session-facts.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Practice Session Facts</title>
</head>
<body>
  <h1>Know the practice session</h1>
  <dl>
    <dt>Room</dt>
    <dd>Room 6, second floor.</dd>
    <dt>Bring</dt>
    <dd>Your notebook and one saved HTML page.</dd>
    <dt>Goal</dt>
    <dd>Explain the heading and paragraph in your own words.</dd>
    <dd>Check the saved page with a partner.</dd>
  </dl>
</body>
</html>
Browser previewDocument title: Practice Session Facts

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

The Goal name has two dd elements. Both explain the goal; they do not create an additional unnamed term. Read the source from top to bottom and identify each group's names before reading its descriptions.

Longer explanations and list choices

A dd can contain paragraphs or a list when the description genuinely needs them. For example, the value for Bring can be a short ul. Keep the ul inside that dd. The dt should name the subject, rather than contain another heading structure or a full section of prose.

HTML fragment — part of a document
<dl>
  <dt>Bring</dt>
  <dd>
    <ul>
      <li>Notebook</li>
      <li>Saved HTML file</li>
    </ul>
  </dd>
</dl>

For a larger comparison with shared column headings, a table may be clearer. For a sequence of tasks, use ol. For a collection of supplies alone, use ul. Choose the structure that expresses the relationship, rather than using dl just to produce an indent.

Optional grouping with div

Later, when learning layout, you may see each complete dt/dd group wrapped in a div inside dl. This is allowed and can help style a group. Do not mix bare dt/dd children and div-wrapped groups in the same dl. For now, the simple direct dt/dd form is enough; a wrapping div does not change the meaning of the words.

Problem and solution: every line looks like another term

Problem: a student writes dt for both Editor and its explanation. They expect the browser to know that the second line is the meaning.

Solution: change the explanation's tags to dd. HTML uses the element roles, not the length of the sentence, to describe the relationship. Then check that every group has at least one name and one description, in that order.

Common mistakes and useful tips

  • Putting dt and dd outside dl.
  • Adding li because every list is assumed to need it.
  • Writing all names first and all descriptions later, losing the intended groups.
  • Using a dt without any following dd in its group.
  • Choosing dl purely to create left and right visual columns.
  • Depending on indentation alone to communicate the relationship.
  • Writing a difficult definition before introducing the words it uses. Prefer a familiar explanation and a small example.

Practice questions

  1. What relationship does a description list represent?
  2. Which element holds the name and which holds its explanation?
  3. Does a dl need li elements?
  4. Can two dt elements share one dd? Give a suitable use.
  5. Which list would you use for four steps in a fixed order?
  6. Write a complete page describing a study session with the names Place, Bring and Goal. Give Goal two descriptions and check which name each dd belongs to.
Check your practice answers
  1. It groups names or terms with their descriptions or values.
  2. Dt holds the name; dd holds the explanation or value.
  3. No. Use dt and dd groups inside dl instead.
  4. Yes. Two alternate names for the same thing can share an explanation.
  5. Ol, with an li for each step.
  6. Use a dl with a dt for each name. Put the two Goal descriptions consecutively after its dt. Include the normal document structure and check the groups in source order.

Interview questions

Is a description list only for dictionary definitions?

No. It can also express other name-value relationships, such as session details. The names and their descriptions must form meaningful groups.

Must every dt be followed immediately by exactly one dd?

No. A group can contain multiple names followed by multiple descriptions. Keep the names together before their group's descriptions so that the association is clear.

Can dd contain a list or paragraphs?

Yes. A description can need more than one sentence or several items. Keep those elements inside the dd that owns them.

How would you choose between dl and a table?

Use dl for names with descriptions. A table suits data organised by shared rows and columns, especially when readers need to compare values under common headings. Appearance alone should not make the decision.

Quick revision

  • Dl is a description list; dt names; dd describes.
  • Each group has names first, then descriptions.
  • Do not insert li into the basic dt/dd pattern.
  • Use the simplest structure that accurately expresses the content.