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 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.
This tag is new in HTML5.
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 > <!-- 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:
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 > <!-- 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:
Supported Browsers:
- Google Chrome 12.0 and above
- Edge 79.0 and above
- Firefox 49.0 and above
- Opera 15.0 and above
- Safari 6.0 and above
Please Login to comment...