# `[name] for <details>`

> The `name` HTML attribute of the `<details>` element groups several elements into an exclusive accordion.

## How do I make an exclusive accordion with details and name?

The attribute that groups several `<details>` elements under one name so that only one of them can be open at a time. Opening one element automatically closes the others, which creates an exclusive accordion without JS.

- Topic: Element Attributes
- Type: attribute
- Browser support: Chrome 120+, Chrome Android 120+, Edge 120+, Firefox 130+, Firefox Android 130+, Safari 17.2+, Safari iOS 17.2+

## Example

Wrong:

```js
panels.forEach((p) => p.addEventListener('toggle', () => {
  if (p.open) panels.forEach((o) => {
    if (o !== p) o.open = false;
  });
}));
```

Right:

```html
<details name="faq"><summary>Shipping</summary>...</details>
<details name="faq"><summary>Returns</summary>...</details>
```

Sharing a `name` makes the browser close the other panels, so no script is needed.

## Common mistakes

- Expecting one panel to stay open: the user can still close all of them.

## Key points

- Every `<details>` in the group has the same `name` value.
- Each `<details>` starts with a `<summary>` that describes its content.
- No JS closes the other panels by hand, the browser does it.

## Interview questions

### Can I keep one details panel open by default?

Yes. Add `open` to one `<details>` in the group. If several have it, only the first stays open.

### Does the name attribute submit with a form?

No. On `<details>` it only groups panels into an accordion.

## Related cards

- [`<details>`](https://wonderium.dev/html/details.md)
- [`<summary>`](https://wonderium.dev/html/summary.md)
- [::details-content](https://wonderium.dev/css/details-content.md)
- [button](https://wonderium.dev/a11y/button.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/details-name
- Last updated: 2026-11-25
