Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML element: dd

The description element supplies a definition, explanation, or value for the preceding name or names in the same description-list group.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<dl><dt>Term</dt><dd>Description</dd></dl>

In a dl, a group consists of one or more dt elements followed by one or more dd elements; several names can share descriptions, and one name can have several descriptions.

Groups can be direct sequences of dt and dd, or be wrapped in a div child of dl; do not mix those two structures in one list.

dd accepts flow content such as p paragraphs and lists. Default indentation is CSS presentation, so use margin for spacing rather than inventing a description list.

The example follows nextElementSibling while tagName is DD, and separately counts every dt and dd.

Examples

<!doctype html>
<meta charset="utf-8">
<dl id="glossary">
  <dt id="parser">Parser</dt>
  <dd>Builds the DOM.</dd>
  <dd>Recovers from syntax errors.</dd>
  <dt>DOM</dt>
  <dd>Document object model.</dd>
</dl>
<output id="result"></output>
<script>
const glossary = document.querySelector("#glossary");
const parser = document.querySelector("#parser");
let node = parser.nextElementSibling;
let parserDescriptions = 0;
while (node?.tagName === "DD") { parserDescriptions++; node = node.nextElementSibling; }
document.querySelector("#result").textContent = `terms=${glossary.querySelectorAll("dt").length}; descriptions=${glossary.querySelectorAll("dd").length}; parserDescriptions=${parserDescriptions}; firstParent=${parser.nextElementSibling.parentElement.id}`;
</script>

Result

terms=2; descriptions=3; parserDescriptions=2; firstParent=glossary

The result verifies two names, three descriptions, and two descriptions for Parser; it does not automatically determine the relationship type.

Sources