The popover attribute turns any element into a popover that the browser shows in the top layer (no z-index or overflow clipping problems), with light dismiss (click outside or press Escape) and one-open-at-a-time behaviour for popover="auto". A button with popovertarget toggles it without JavaScript, and the browser wires up aria-expanded and sensible focus behaviour. It's Baseline in all major browsers since 2024. Use it for non-modal, transient UI: menus, pickers, tooltips-with-content, toasts and teaching bubbles. Use <dialog> with showModal() when the rest of the page must be blocked.
<button popovertarget="account-menu">Account</button>
<div id="account-menu" popover>
<a href="/profile">Profile</a>
<a href="/settings">Settings</a>
<button popovertarget="account-menu" popovertargetaction="hide">Close</button>
</div>
[popover] { margin: 0; padding: .5rem; border-radius: 8px; }
[popover]:popover-open { /* open state */ }
[popover]::backdrop { background: transparent; }
menu.showPopover(); menu.hidePopover(); menu.togglePopover();
menu.addEventListener('toggle', e => console.log(e.newState)); // "open" | "closed"
popover / popover="auto" | popover="manual" | popover="hint" | |
|---|---|---|---|
| Light dismiss | Yes | No | Yes |
| Closes other popovers | Yes, other auto ones (except ancestors in a nested chain) | No | Closes other hints only |
| Use for | Menus, pickers | Toasts, persistent panels you close in code | Hover/focus tooltips |
hint is newer and Chromium-only at the time of writing, so feature-detect it. Nested auto popovers (submenus) stay open when the relationship is established through popovertarget or DOM nesting.
| Need | Choose |
|---|---|
| Block the page; the user must respond (confirm delete, sign-in) | <dialog> + showModal() |
| Transient, dismissible, page stays usable | popover |
| Non-modal dialog semantics (a chat panel) | <dialog popover> gives dialog role + popover behaviour |
A popover is in the top layer and centred by default (via UA styles), not attached to its trigger. To place it next to the button, use CSS anchor positioning:
#account-menu {
position-anchor: --account;
position-area: block-end span-inline-end;
position-try-fallbacks: flip-block;
}
button[popovertarget="account-menu"] { anchor-name: --account; }
Anchor positioning shipped in Chromium in 2024 and in Safari 26. Firefox has been the last to arrive, so check current support and keep a JS fallback such as Floating UI where needed.
role="menu" requires arrow-key handling, so prefer the simpler disclosure pattern for navigation.auto popover when opened (focus does return to the invoker on light dismiss in many cases). Move focus deliberately for menus and pickers.popovertarget only works on <button> and <input type="button">, which is a good nudge toward correct semantics.popover for modal flows, so the background stays interactive.@starting-style and transition-behavior: allow-discrete on display and overlay. Support varies, so keep animations optional.showPopover().popovertarget.<dialog> and when to combine them.Spotted a mistake or a rights concern? Report an issue