The <details>
and <summary>
tags are used to create an accordion element that can be dynamically opened and closed. These tags are unique as they can add dynamic visual effects even without CSS and JavaScript. These tags are often used to hide detailed information to simplify website design at a glance.
The <summary>
element should be nested under the <details>
element. After the <summary>
element, you can describe what you want to show when the box is open. Here is an example of an implementation of the <detail>
and <summary>
elements.
<details>
<summary>Weather in London: Sunny</summary>
<ul>
<li>20 °C</li>
<li>Humidity: 43%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
You'll see the output below.
You can use the open
attribute if you want to open the box when a browser loads the page.
!
and hit tab or enter to create an html template.<title>
section to 7. Bridging HTML and CSS.In the <body>
section, type (copy & paste) the following code:
<h1>Chapter 7. Bridging HTML and CSS</h1>
<h2>Details and Summary</h2>
<details open>
<summary>Weather in London: Sunny</summary>
<ul>
<li>20 °C</li>
<li>Humidity: 43%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
<details open>
<summary>Weather in New York: Cloudy</summary>
<ul>
<li>17 °C</li>
<li>Humidity: 47%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
After editing the file, make sure that you save it (⌘ + S for Mac, Ctrl + S for Windows).
You can also check the sample result here (Demo Site ).
The <details>
and <summary>
tags are used to create an accordion element that can be dynamically opened and closed. These tags are unique as they can add dynamic visual effects even without CSS and JavaScript. These tags are often used to hide detailed information to simplify website design at a glance.
The <summary>
element should be nested under the <details>
element. After the <summary>
element, you can describe what you want to show when the box is open. Here is an example of an implementation of the <detail>
and <summary>
elements.
<details>
<summary>Weather in London: Sunny</summary>
<ul>
<li>20 °C</li>
<li>Humidity: 43%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
You'll see the output below.
You can use the open
attribute if you want to open the box when a browser loads the page.
!
and hit tab or enter to create an html template.<title>
section to 7. Bridging HTML and CSS.In the <body>
section, type (copy & paste) the following code:
<h1>Chapter 7. Bridging HTML and CSS</h1>
<h2>Details and Summary</h2>
<details open>
<summary>Weather in London: Sunny</summary>
<ul>
<li>20 °C</li>
<li>Humidity: 43%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
<details open>
<summary>Weather in New York: Cloudy</summary>
<ul>
<li>17 °C</li>
<li>Humidity: 47%</li>
<li>Wind: 2 m/s</li>
</ul>
</details>
After editing the file, make sure that you save it (⌘ + S for Mac, Ctrl + S for Windows).
You can also check the sample result here (Demo Site ).