How to define additional details that the user can view or hide?

In this article, we define additional details that the user can view or hide By using the details Element in The Document, It 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. The content of the details tag is visible when open the set attributes.

Syntax:

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

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
Define additional details that the user can view or hide.
</title
        <style
            summary { 
                font-size:40px; 
                color:#090; 
                font-weight:bold; 
            
        </style
    </head
    <body
        <h2>
Define additional details that the user can view or hide
       </h2>
        <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
    </body
</html>

chevron_right


Output:
Before clicking on details Element:

After Clicking On Button:

Supported Browsers are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.