<summary> : Summary element

Introduction

The <summary> element in HTML is used as part of the <details> element to provide a summary or heading for the content that can be expanded or collapsed. It represents a summary, title, or label for the content within a <details> element.

Here’s an example of how you might use the <summary> element within a <details> element:

Output:

And when we click on triangle button we get more information about title.

In this example:

  • The <details> element contains content that can be toggled between being visible or hidden.
  • The <summary> element serves as a heading or label for the content within the <details> element. When clicked, it toggles the visibility of the content.
  • The content inside the <details> element (in this case, a <p> element) is initially hidden and becomes visible when the summary is clicked.

This pattern is commonly used for creating collapsible sections of content, such as FAQ sections or expandable sections of a webpage.

Leave a Comment