HTML5 | <details> tag

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 which 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 . . . >
</details>

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>details tag</title>
        <style>
            summary {
                font-size:40px;
                color:#090;
                font-weight:bold;
            }
        </style>
    </head>
    <body>
        <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:
detail tag



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

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

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>open attribute in detail tag</title>
        <style>
            summary {
                font-size:40px;
                color:#090;
                font-weight:bold;
            }
        </style>
    </head>
    <body>
        <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>
    </body>
</html>                    

chevron_right


Output:
open attributes

Browser Support: Since this tag is included in HTML 5, so all the browsers do not support this tag.
The browsers which supports this tag are:

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


My Personal Notes arrow_drop_up

A tech fanatic who can code stuff

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.



Improved By : shubham_singh



Article Tags :
Practice Tags :


1


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