Tag <summary> In HTML
Today we will cover Tag summary examples. By using examples, we anticipate meeting the learning objectives.
The <summary> tag is an HTML5 element that is used to define a visible heading for a <details> element, which can be expanded or collapsed. The <details> and <summary> elements are often used together to create collapsible sections of content on a web page.
The <summary> tag indicates a prominent heading for the <details> tag.
Detail information can be viewed or hidden by clicking on the heading.
Here is the <summary> tag example:
Example: 
Here is an example of the <summary> tag in detail:
Example: 
Here’s another detailed example of using the <summary> and <details> tags:
Example: 
CSS can also be applied to <summary> and <details> tag. See the example below:
Example: 
Tag Summary Uses
The <summary> tag is primarily used in conjunction with the <details> tag to create collapsible sections of content on a web page. Here are some of the common uses of the <summary> tag:
- When used with the <details> tag, the <summary> tag provides a visible heading for the collapsible section. This allows the user to expand or collapse the content within the section by clicking on the heading. This is useful for presenting large amounts of content in a compact and organized way.
- The <summary> tag can also be used to create accordion menus, which are a series of collapsible sections that allow the user to expand or collapse content as needed. Accordion menus are commonly used in website navigation to present a large number of options in a user-friendly way.
- The <summary> tag can also be used to provide context for the content within a collapsible section. By using a descriptive heading, you can make it clear to the user what information is contained within the section, and help them quickly find the information they need.
- Using the <summary> tag can also help improve the accessibility of your website, as it allows users with screen readers to quickly identify and navigate to the content they need. When used properly, the <summary> tag can make your website more user-friendly and accessible to a wider range of users.
Attributes
Global
The Tag summary <summary> similarly handles Global Attributes in HTML.
Event
The Tag <summary> also accepts the Event Attributes in HTML.
Browser Compatibility
In the following table, the numbers indicate the version of the browser that is compatible with the Tag Summary.
Element | |||||
---|---|---|---|---|---|
<summary> | 12.0 | 79.0 | 49.0 | 6.0 | 15.0 |
Predefined CSS
Tag <summary> element is frequently generated with the given default values:
summary { display: block; }
HTML Tag Summary Advantages
Here are some of the key advantages of using the <summary> tag:
- The <summary> tag can help make your website more user-friendly by allowing you to present large amounts of content in a compact and organized way. By providing a visible heading for collapsible sections, users can quickly scan the page to find the information they need, without being overwhelmed by too much content at once.
- Using the <summary> tag can also improve the accessibility of your website by making it easier for users with screen readers to navigate and understand your content. By using descriptive headings in the <summary> tag, you can provide context for the content within the collapsible section, which can make it easier for users with disabilities to find the information they need.
- By using collapsible sections of content, you can save valuable space on your web page. This is particularly useful for mobile devices, where screen real estate is limited. By using the <summary> tag to create collapsible sections, you can make your content more accessible and easier to navigate, without sacrificing valuable screen space.
- The <summary> tag is easy to implement, and can be added to any web page with just a few lines of HTML code. This makes it a simple and effective way to improve the user experience on your website, without requiring a lot of technical expertise or resources.