
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to specify that the details should be visible to the user in HTML?
The task we are going to perform in this article is how to specify that the details should be visible to the user in HTML.
The user can open and close more details by using the <details> tag, which specifies them. Create interactive widgets that the user can open and close by using the <details> tag. The widget's closed state by default. It expands when you open it, revealing the contents. The details tag is a container for any kind of content.
Syntax
Following is the syntax for <details> tag
<details> <summary> Text content </summary> <div> Content . . . </div> </details>
Let’s dive into the following examples to understand more about how to specify that the details should be visible to the user in HTML.
Example 1
In the following example we are using details element to create an interactive widget.
<!DOCTYPE html> <html> <head> <style> summary { font-size:40px; color:lightgreen; font-weight:bold; } </style> </head> <body> <details> <summary>TUTORIALSPOINT</summary> <p>A computer science portal for eveyone</p> <div>It is a computer science portal where you can learn programming.</div> </details> </body> </html>
On executing the above script, it will generate an output consisting of an interactive widget which allows the user to open or hide the text.
By clicking on the interactive widget, the text inside it will be shown to the user and you can close it when it is needed.
Example 2
Considering the following example where we are using CSS to style <details> and <summary>.
<!DOCTYPE html> <html> <head> <style> summary { padding: 4px; width: 200px; background-color: #A3E4D7 ; border: none; box-shadow: 1px 1px 2px #A569BD ; cursor: pointer; } p { background-color: #85929E ; padding: 4px; margin: 0; box-shadow: 1px 1px 2px#A569BD; } </style> </head> <body> <details> <summary>MS DHONI</summary> <p>Mahendra Singh Dhoni is an Indian former international cricketer who was captain of the Indian national cricket team in limited-overs formats from 2007 to 2017 and in Test cricket from 2008 to 2014.</p> </details> </body> </html>
When the script gets executed, it will generate an output displaying the <detail> tag content used in the script applied with CSS. If the user clicks on the detail box, the matter mentioned in the
tag on the webpage, as well as the CSS applied, will be displayed.
- Related Articles
- How to specify that the form should not be validated when disabled in HTML?
- How to specify the number of visible options for in HTML?
- How to specify that an element should be pre-selected when the page loads in HTML?
- How to specify that an option should be pre-selected when the page loads in HTML?
- How to specify that the target will be downloaded when a user clicks on the hyperlink in HTML?
- How to specify that the element should automatically get focus when the page loads in HTML?
- How to specify whether the form-data should be encoded while submitting to the server with HTML?
- How to specify that a user can enter more than one value in HTML?
- How to specify whether the content of an element should be translated or not in HTML?
- How to specify that the element must be filled out before submitting the form in HTML?
- How to specify whether the or the element should have autocomplete enabled in HTML?
- How to specify if and how the author thinks the audio/video should be loaded when the page loads in HTML?
- How to set whether an element should be visible in JavaScript?
- How to specify that the element is read-only in HTML?
- How to specify the number of columns a table cell should span in HTML?
