HTML <summary> tag
定义和用法
<summary>
标签为 <details> 元素 定义了一个可见的标题。点击标题可以查看/隐藏详细信息。
注意:<summary>
元素应该是 <details> 元素 的第一个子元素。
另请参阅:
HTML DOM 参考手册:Summary 对象
实例
例子 1
使用 <summary>
Element:
<details> <summary>Future World Center (Epcot Center)</summary> <p>Epcot is a theme park in Walt Disney World Resort, featuring exciting attractions, international pavilions, award-winning fireworks, and seasonal events.</p> </details>
例子 2
使用 CSS 设置 <details> 和 <summary>
的样式:
<html> <style> details > summary { padding: 4px; width: 200px; background-color: #eeeeee; border: none; box-shadow: 1px 1px 2px #bbbbbb; cursor: pointer; } details > p { background-color: #eeeeee; padding: 4px; margin: 0; box-shadow: 1px 1px 2px #bbbbbb; } </style> <body> <details> <summary>Future World Center (Epcot Center)</summary> <p>Epcot is a theme park in Walt Disney World Resort, featuring exciting attractions, international pavilions, award-winning fireworks, and seasonal events.</p> </details> </body> </html>
Global Attributes
<summary>
The tag also supports Global Attributes in HTML.
Event Attributes
<summary>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will display the following default values <summary>
Element:
summary { display: block; }
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
12.0 | 79.0 | 49.0 | 6.0 | 15.0 |