HTML Tutorial

HTML Tag: <summary>

Purpose:

To summarize the content of a section, providing an overview that can be expanded or collapsed.

Usage:

  1. Place the <summary> tag before the content you want to summarize.
  2. Use the <summary></summary> structure to wrap the summary text.
  3. Place the detailed content inside a <details> tag.

Attributes:

  • id: Unique identifier for the <summary> tag.
  • class: CSS class(es) to apply to the <summary> element.
  • dir: Text direction within the <summary> text (e.g., ltr, rtl).
  • lang: Language of the <summary> text.
  • tabindex: Tab order of the <summary> element.

Examples:

<details>
  <summary>Section Summary</summary>
  <p>Detailed content here...</p>
</details>

Exploring the <summary> Tag:

To explore the <summary> tag, create a simple HTML document with the following code:

<!DOCTYPE html>
<html>
<head>
  <title>Exploring the <summary> Tag</title>
</head>
<body>
  <details>
    <summary>Section Summary</summary>
    <p>Detailed content here...</p>
  </details>
</body>
</html>

Open the HTML file in a web browser. The "Section Summary" text will be visible, and clicking on it will expand the detailed content.