Description lists help organize pairs of terms and their explanations clearly on a webpage.
Description lists in HTML
<dl> <dt>Term</dt> <dd>Description of the term.</dd> </dl>
<dl> wraps the whole list.
<dt> is for the term or name.
<dd> is for the description or details.
<dl> <dt>HTML</dt> <dd>Language for web pages.</dd> <dt>CSS</dt> <dd>Styles web pages.</dd> </dl>
<dl> <dt>JavaScript</dt> <dd>A programming language for the web.</dd> <dd>Used to make pages interactive.</dd> </dl>
<dl> <dt>FAQ</dt> <dd>Frequently Asked Questions.</dd> </dl>
This example shows a description list with three web terms and their explanations. It uses semantic HTML and simple styling for clarity and accessibility.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Description List Example</title> <style> body { font-family: Arial, sans-serif; padding: 1rem; max-width: 600px; margin: auto; } dl { background-color: #f9f9f9; border: 1px solid #ccc; padding: 1rem; border-radius: 0.5rem; } dt { font-weight: bold; margin-top: 1rem; color: #2a2a2a; } dd { margin-left: 1.5rem; margin-bottom: 0.5rem; color: #555; } </style> </head> <body> <h1>Web Development Terms</h1> <dl aria-label="Glossary of web development terms"> <dt>HTML</dt> <dd>Standard language for creating web pages.</dd> <dt>CSS</dt> <dd>Styles the appearance of web pages.</dd> <dt>JavaScript</dt> <dd>Makes web pages interactive and dynamic.</dd> </dl> </body> </html>
Description lists are great for pairing terms and explanations in a clear, readable way.
They improve accessibility by using semantic tags that screen readers understand.
Use <dt> and <dd> in pairs inside <dl> for best structure.
Description lists organize terms and their descriptions clearly.
Use <dl>, <dt>, and <dd> tags together.
They help both sighted users and screen readers understand content better.
Practice
<dl> element in HTML?Solution
Step 1: Understand the role of
The<dl><dl>tag is used to group terms and their descriptions in a list format.Step 2: Compare with other list types
Unlike ordered (<ol>) or unordered (<ul>) lists,<dl>is specifically for description lists.Final Answer:
To create a description list that pairs terms with their descriptions -> Option DQuick Check:
Description list = <dl> [OK]
- Confusing <dl> with <ul> or <ol>
- Thinking <dl> creates tables
- Using <dl> for paragraphs
Solution
Step 1: Identify the container tag for description lists
The<dl>tag is the container that starts a description list.Step 2: Understand roles of
<dt>and<dd><dt>defines a term, and<dd>defines its description, but they do not start the list.Final Answer:
<dl> -> Option AQuick Check:
Start description list = <dl> [OK]
- Using <dt> or <dd> as the list container
- Using non-existent <list> tag
- Confusing with unordered list tags
<dl> <dt>HTML</dt> <dd>HyperText Markup Language</dd> <dt>CSS</dt> <dd>Cascading Style Sheets</dd> </dl>
Solution
Step 1: Understand the structure of the description list
The<dl>contains pairs of<dt>(terms) and<dd>(descriptions).Step 2: Visualize the browser rendering
Each term appears on its own line, with its description indented below it, forming a clear term-description pair.Final Answer:
A list showing 'HTML' with 'HyperText Markup Language' below it, then 'CSS' with 'Cascading Style Sheets' below it -> Option CQuick Check:
dl shows terms with indented descriptions [OK]
- Thinking it creates bulleted or numbered lists
- Expecting terms and descriptions on the same line
- Ignoring indentation of descriptions
<dl> <dt>JavaScript</dt> <dt>A programming language</dt> </dl>
Solution
Step 1: Check tag usage in description lists
<dt>is for terms,<dd>is for descriptions. Terms should be followed by descriptions.Step 2: Identify the problem in the code
The code uses two<dt>tags in a row without a<dd>describing the first term.Final Answer:
Using two <dt> tags without a <dd> for description -> Option BQuick Check:
Term must have description after it [OK]
- Using multiple <dt> tags without <dd>
- Confusing <dt> and <dd> roles
- Forgetting to close <dl>
Solution
Step 1: Understand multiple descriptions for one term
A term (<dt>) can have multiple descriptions (<dd>) listed below it.Step 2: Analyze each option's structure
- Fruit
- Apple
- Banana
- Vegetable
- Carrot
<dd>tags under one<dt>term. Other options misuse tags or mix terms and descriptions incorrectly.Final Answer:
Option A shows correct multiple descriptions for one term -> Option AQuick Check:
Multiple- under one
- is valid [OK]
- Using multiple <dt> tags for descriptions
- Placing <dd> before <dt>
- Using only <dd> without <dt>
Ready to prove it?
Pass the test and this pattern moves unknown
