<summary>

The HTML (<summary>) element serves as a summary or title for a (<details>) element, allowing users to click and expand it to show or hide further information, thereby improving interactivity and content organization.

<summary> Tag

The <summary> tag in HTML serves as a visible heading for the <details> element. It functions as a clickable title that enables users to show or hide the content inside the <details> element.

Syntax

index.html
<details>
  <summary>Summary text</summary>
  <p>Additional details go here.</p>
</details>

<summary> Demo

Click to view more information

This is the additional information that appears when you click the summary.

index.html
<details>
  <summary>Click to view more information</summary>
  <p>
    This is the additional information that appears when you click the summary.
  </p>
</details>

Attributes

Key Points

The <summary> tag provides a concise, clickable description for the content inside the <details> element.

  • The <details> element can be expanded or collapsed, making it useful for interactive sections such as FAQs or hidden content.
  • By default, the content inside <details> is hidden. Clicking the <summary> reveals or hides it.

See Also

See also <details>

Conclusion

The <summary> tag provides a clickable heading for the <details> element, allowing users to reveal or hide additional content. This feature is particularly useful for creating interactive sections like FAQs or hidden information. By default, the content within <details> is hidden, and clicking the <summary> tag toggles its visibility.