<details> Tag in HTML

The <details> tag is used to create a disclosure widget in HTML that allows users to show or hide additional content on demand. This tag is especially useful for hiding long descriptions, FAQs, or any information that users may want to access optionally. The <summary> element is often used as the visible heading for the <details> content.

Key Points on <details> Tag:

Syntax of <details> Tag:

Syntax Example

<details>
            <summary>Summary Text</summary>
            Additional content goes here.
        </details>
                

Example of <details> Tag in HTML:

This example shows how to use the <details> tag to hide and show a section about product details.

Code Example


        <details>
            <summary>Product Details</summary>
            <p>This is a high-quality, eco-friendly product made with sustainable materials.</p>
        </details>
                

Output

Product Details This is a high-quality, eco-friendly product made with sustainable materials.

The <details> tag is beneficial for content that may not be relevant to all users immediately. It provides a cleaner user interface by hiding additional information until it is needed, enhancing readability and user experience.