HTML <dt> Tag โ Definition Term
๐ Introduction
The <dt> tag is used to define a term (title) inside a description list (<dl>).
It is always paired with:
<dd>โ description of the term
Together they form a structured definition system.
๐งฑ Syntax
<dl>
<dt>Term</dt>
<dd>Description</dd>
</dl>
๐ก Example
<!DOCTYPE html>
<html>
<head>
<title>DT Example</title>
</head>
<body>
<h2>Web Technologies</h2>
<dl>
<dt>HTML</dt>
<dd>Used to structure web pages</dd>
<dt>CSS</dt>
<dd>Used to style web pages</dd>
<dt>JavaScript</dt>
<dd>Used to add interactivity</dd>
</dl>
</body>
</html>
๐ฅ๏ธ Output Explanation
- Each
<dt>shows the term (title) - Each
<dd>shows the meaning or description - They work together inside
<dl>
๐ฏ When to Use <dt>
Use <dt> for:
- Words in a glossary
- Titles in definitions
- Keys in key-value data
Example:
<dl>
<dt>API</dt>
<dd>Application Programming Interface</dd>
</dl>
๐ง Important Rule
๐ <dt> cannot be used alone
It must be inside <dl>:
โ Correct:
<dl>
<dt>HTML</dt>
<dd>Markup language</dd>
</dl>
โ Wrong:
<dt>HTML</dt>
โ๏ธ <dt> vs <dd>
| Tag | Meaning |
|---|---|
<dt> |
Term / title |
<dd> |
Description |
๐จ Styling Example
<dl>
<dt style="font-weight:bold;">HTML</dt>
<dd>Structure of web pages</dd>
</dl>
๐ซ Common Mistakes
- Using
<dt>outside<dl>โ - Forgetting
<dd>โ - Using it like a normal list item โ
๐งช Mini Exercise
Create a glossary page with:
- 5 terms using
<dt> - Their meanings using
<dd> - Style terms to be bold or colored