You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Safari 17.2 now supports the name attribute on the <details> element — which moves some commonly-used functionality from needing JavaScript to being baked into HTML. If you use the name attribute to give a series of details elements the same name, then only one in the series will be open at a time.
<detailsname="foobar" open><summary>Item 1</summary><p>Since this first item has an open attribute, it’s open by default.</p></details><detailsname="foobar"><summary>Item 2</summary><p>When you clicked this item, any other open item will automatically close.</p></details><detailsname="foobar"><summary>Item 3</summary><p>Now, developers don’t have to write any JavaScript to get this behavior.</p></details>
Any time a user clicks to open a second item, the first item automatically closes. This can make for a better user experience, although do make sure it’s right for your project. Think about users who might want or need to compare one item to another. Consider whether to not it will be annoying to have to tap over and over on each bit of content in order to read each one. This pattern can be frustrating when used inappropriately — even inaccessible.
Activity
thomas-price commentedon Jan 14, 2024
Chrome/Edge v120 and Opera v106 now support this
westonruter commentedon Oct 22, 2025
Follow ups:
nameattribute to the<details>elementEditor: Allow `name` attribute on the `details` element in KSES.
Editor: Allow `name` attribute on the `details` element in KSES.
Editor: Allow `name` attribute on the `details` element in KSES.
Update and enhance kses functions (#2722)