Interactive Tutorial Transcript
Sometimes we need to display a list of terms and their descriptions, like a glossary or a metadata list. HTML provides the Definition List for this purpose using the <dl> tag.
We start with the wrapper tag <dl>. This stands for 'Definition List'. It creates the container where our terms and descriptions will live.
<dl>
Inside the list, we define a term using the <dt> tag (Definition Term). This acts like a label or a heading for the specific item we want to define.
<dl>
<dt>HTML</dt>
Following the term, we provide the definition using the <dd> tag (Definition Description). Browsers typically indent this automatically to visually separate it from the term.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language.</dd>
Checkpoint: Which tag is used to wrap the entire list?
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language.</dd>
And finally, we must close the list with the closing tag </dl>. Without this, the browser might not know where the list ends.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language.</dd>
</dl>
Let's see the result. Notice the indentation of the description. This structure is semantically linked: screen readers know the 'dd' describes the 'dt'.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language.</dd>
</dl>
You can have multiple terms and definitions. For example, adding CSS to our glossary.
<dl>
<dt>HTML</dt>
<dd>Structure.</dd>
<dt>CSS</dt>
<dd>Style.</dd>
</dl>
Checkpoint: Which tag contains the actual description/details?
<dl>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
Great job! You now understand how to build semantic lists for glossaries and metadata.
<h1>Done!</h1>
Practice makes perfect. Use the editor below to create your own dictionary list and unlock new achievements!