# \[popover\]

> The `popover` HTML global attribute turns an element into a popover that is displayed on top of other content.

## How do I make a popover in HTML without JavaScript?

The attribute that turns an element into a popover rendered in the top layer above all other content. Supports light dismiss with 'auto' value, can be toggled declaratively with `popovertarget` or via JS methods, without any extra scripts for focus and closing logic.

- Topic: Global Attributes
- Type: attribute
- Browser support: Chrome 114+, Chrome Android 114+, Edge 114+, Firefox 125+, Firefox Android 125+, Safari 17+, Safari iOS 17+

## Example

Wrong:

```html
<button onclick="menu.style.display = 'block'">Menu</button>
<div id="menu" style="display: none">...</div>
```

Right:

```html
<button popovertarget="menu">Menu</button>
<div id="menu" popover>...</div>
```

The browser shows the popover in the top layer and closes it on outside click or Esc.

## Common mistakes

- Setting `display: flex` on the popover selector, so it stays visible when closed.
- Using `popover='manual'` and then wondering why outside clicks and Esc do not close it.

## Key points

- The popover is opened by a `<button>` with `popovertarget`, not by toggling a class or `display` in JS.
- There is no `z-index` hack: a popover is shown in the top layer.
- Styles for the open state are in `:popover-open`, not on the base selector.
- Blocking content that needs a response uses a modal `<dialog>`, not a popover.

## Interview questions

### What is the difference between popover='auto' and popover='manual'?

'auto' closes on outside click, Esc and when another auto popover opens. 'manual' stays open until you close it.

### Is a popover the same as a dialog?

No. A popover is non-modal and the page stays usable. Use a modal `<dialog>` when the user must respond first.

### How do I animate a popover opening?

Style `:popover-open` for the open state and use `@starting-style` with transitions on `display` and `overlay`.

## Related cards

- [\[popovertarget\]](https://wonderium.dev/html/popovertarget.md)
- [.showPopover()](https://wonderium.dev/js/show-popover.md)
- [:popover-open](https://wonderium.dev/css/popover-open.md)
- [`<dialog>`](https://wonderium.dev/html/dialog.md)
- [::backdrop](https://wonderium.dev/css/backdrop.md)

---

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