Skip to content
Related Articles

Related Articles

Improve Article

HTML5 | <details> tag

  • Difficulty Level : Basic
  • Last Updated : 24 Feb, 2021

The <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. The content of the details tag is visible when open the set attributes. The summary tag is used with the details tag for specifying visible heading. 

Syntax: 
 

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

Attributes:

details open: The detail tag has an attribute called open which is used to display the hidden information by default. 
 
Example: The below code explains the details tag.
 

HTML




<!DOCTYPE html>
<html>
    <body>
        <h1>GeeksforGeeks</h1>
        <!-- deatils 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>
         <!-- deatils tag ends here -->
        </details>
    </body>
</html>

Output: 
 



Syntax: 
 

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

Example: The below code explains the details open tag in details tag.
 

HTML




<!DOCTYPE html>
<html>
    <body>
        <h1>GeeksforGeeks</h1>
        <!-- deatils 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>
         <!-- deatils open tag ends here -->
        </details>
    </body>
</html>                   

Output: 
 

Supported Browsers: 

  • Google Chrome 12.0 and above
  • Firefox 49.0 and above
  • Opera 15.0 and above
  • Safari 6.0 and above

 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :