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
Dl, dt and dd
<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>Complete program: 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>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.
More than one name or description
<dl>
<dt>USB drive</dt>
<dt>Pen drive</dt>
<dd>A small portable device used to store and move files.</dd>
</dl>- 1Open dl
- 2Write one or more dt names
- 3Follow with their dd descriptions
- 4Start the next group of names
Several names can share descriptions. Keep each group together.
Complete program: 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>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.
Longer explanations and list choices
<dl>
<dt>Bring</dt>
<dd>
<ul>
<li>Notebook</li>
<li>Saved HTML file</li>
</ul>
</dd>
</dl>Optional grouping with div
Problem and solution: every line looks like another term
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
What relationship does a description list represent? Which element holds the name and which holds its explanation? Does a dl need li elements? Can two dt elements share one dd? Give a suitable use. Which list would you use for four steps in a fixed order? 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
It groups names or terms with their descriptions or values. Dt holds the name; dd holds the explanation or value. No. Use dt and dd groups inside dl instead. Yes. Two alternate names for the same thing can share an explanation. Ol, with an li for each step. 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?
Must every dt be followed immediately by exactly one dd?
Can dd contain a list or paragraphs?
How would you choose between dl and a table?
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.