Publish in HTML Tutorial el 23/05/2025 20:21
The <details> element creates a disclosure widget that contains information that is initially hidden but can be revealed by the user. It's a native HTML way to create collapsible content without JavaScript. The element works with a nested <summary> tag that serves as the clickable header.
Here's the basic structure of a <details> element:
And here's how it renders:
A common use case for <details> is creating FAQ sections without JavaScript.
You can nest <details> elements to create hierarchical structures.
The <details> element can be styled with CSS for better visual appearance.
You can enhance <details> with JavaScript for additional functionality.
Create an accordion where only one item can be open at a time.
open
attribute to make a details element expanded by default: <details open>
toggle
event fires when the state changes between open and closed::marker
pseudo-elementThe <details> element is supported in all modern browsers, but for older browsers like Internet Explorer, you might need a polyfill. Always test your implementation across target browsers.
The <style> HTML element contains style information for a document, or part of a document. ...
The <strong> element is used to indicate that its content has strong importance, seriousnes...
The <span> element is an inline container used to mark up a part of a text or document. Unl...
The <source> element is used to specify multiple media resources for media elements like &l...
The <small> element is used to represent side-comments and small print, typically for discl...
HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...