Open In App

HTML5 <details> Tag

Last Updated : 29 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML <details> Tag is used for the content/information which is initially hidden but could be displayed if the user wishes to see it. This tag is used to create an interactive widget that the user can open or close.

It is used with the <summary> tag, which provides the title or header for the details section. It’s generally used for FAQs, dropdown menus, or to show/hide additional content.

Syntax

<details>
    <summary>  Text content  </summary>
    <div> Content... >
</details>

Attribute

Attribute Value

Description

details open

The detail tag has an attribute called open which is used to display the hidden information by default. 

Event

Events

Description

toggle event

It’s a feature allowing hiding or showing extra information by interaction with the summary in HTML details.

Supported Attributes

This tag is new in HTML5 and also supports the Global Attributes and Event Attributes in HTML.

Example: Implementation of details tag in HTML.

HTML




<!DOCTYPE html>
<html lang="en">
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
   
    <!-- details tag starts here -->
    <details>
        <summary>
            GeeksforGeeks
        </summary>
        <p>
            A computer science portal for geeks
        </p>
        <div>
            It is a computer science portal
            where you can learn programming.
        </div>
       
        <!-- details tag ends here -->
    </details>
</body>
 
</html>


Output: 

wsd

 Example 2: Use of the open attribute with the details tag.

HTML




<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>HTML5 details Tag</title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <!-- details open tag starts here -->
    <details open>
        <summary>GeeksforGeeks</summary>
        <p>A computer science portal for geeks</p>
        <div>
            It is a computer science portal
            where you can learn programming.
        </div>
 
        <!-- details open tag ends here -->
    </details>
</body>
 
</html>


Output: 
 

wsd

Supported Browsers 

  • Google Chrome 12
  • Edge 79
  • Firefox 49
  • Opera 15
  • Safari 6


Previous Article
Next Article

Similar Reads

Why &lt;big&gt; tag is not in HTML5 while &lt;small&gt; tag exists ?
The &lt;big&gt; tag was discontinued in HTML5 while &lt;small&gt; tag is still in handy because &lt;small&gt; tag is frequently used to represent small prints like footnotes, copyright notices, comments etc. Many alternatives for &lt;big&gt; tag are already available such as &lt;h1&gt;, &lt;h2&gt; and so on. In HTML5 instead of using &lt;big&gt;, y
2 min read
Explain the difference between head Tag and header Tag in HTML5 ?
The &lt;head&gt; element is a container for metadata and is placed between the &lt;html&gt; and &lt;body&gt; tags. The &lt;header&gt; is for the main content section's introductory elements, like headings or logos and it mainly focuses on what appears at the top of the webpage. &lt;head&gt; ElementThe &lt;head&gt; element is part of the HTML docume
1 min read
How to define a visible heading for details element in HTML5 ?
In this article, we will learn how to define a visible heading for the &lt;details&gt; element. This element is used to create a widget that reveals information when it is in the "open" state. The state can be toggled by clicking on the element. The contents that have to be revealed are enclosed within the &lt;details&gt; tag. Approach: The &lt;sum
2 min read
What is the use of open Attribute in &lt;details&gt; Tag ?
The "open" attribute in &lt;details&gt; Tags are used to specify whether the additional details within the details element should be initially visible or hidden when the page loads. This attribute is particularly useful for providing users with collapsible sections of content that can be expanded or collapsed as needed, improving the organization a
2 min read
HTML5 MathML &lt;menclose&gt; Tag
The HTML5 MathML &lt;menclose&gt; tag tag is an inbuilt element in HTML5. It is used to renders the contents which is inside of anbenclosing notation specified by the notation attribute. Syntax: &lt;menclose attribute="value "&gt; child elements &lt;/menclose"&gt;Attributes: The tag accepts some attributes which are listed below: class| id| style:
2 min read
HTML5 &lt;article&gt; Tag
The &lt;article&gt; tag is independent of the other content of the page (even though it can be related). In other words, The article element represents a component of a page that consists of self-contained composition in a document, page, or site. For Ex. in syndication. A potential source for Article Element is: A magazine/newspaper articleA blog
2 min read
HTML5 date attribute in &lt;input&gt; Tag
The date attribute in the input tag creates a calendar to choose the date, which includes day, month, and year. Syntax: &lt;input type = "date"&gt;Example 1: Use date attribute in input tag C/C++ Code &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Date Attribute&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action=&quot;/&quot;
1 min read
HTML5 &lt;ruby&gt; Tag
The &lt;ruby&gt; tag in HTML is used to specify the ruby annotation which is a small text, attached with the main text to specify the meaning of the main text. This kind of annotation is used in Japanese publications.Syntax: &lt;ruby attributes&gt; Contents... &lt;/ruby&gt; Note: &lt;ruby&gt; tag contains two other tags which are listed below: &lt;
1 min read
HTML5 rt Tag
The &lt;rt&gt; tag in HTML is used to define the explanation of the ruby annotation which is a small text, attached with the main text. Such kind of annotation is used in Japanese publications. This tag is new in HTML5. Syntax: &lt;rt&gt; Explanation... &lt;/rt&gt; Example 1: This example describes &lt;rt&gt; tag within &lt;ruby&gt; tag. C/C++ Code
1 min read
HTML5 rp Tag
The &lt;rp&gt; tag in HTML is used to provide parentheses around a ruby main text which defines the information. This tag is used when the browser does not support ruby annotations. Such kind of annotation is used in Japanese publications. It is an optional tag. This tag is used within the &lt;ruby&gt; tag. This tag is new in HTML5.Syntax: &lt;rt
1 min read