The Popover API provides developers with a standard, consistent, flexible mechanism for displaying popover content on top of other page content. Popover content can be controlled either using HTML attributes, or via JavaScript.
A very common pattern on the web is to show content over the top of other content, drawing the user's attention to specific important information or actions that need to be taken. This content can take several different names — overlays, popups, popovers, dialogs, etc. We will refer to them as popovers through the documentation. Generally speaking, these can be:
Popovers created using the Popover API are always non-modal. If you want to create a modal popover, a <dialog> element is the right way to go. There is significant overlap between the two — you might for example want to create a popover that persists, but control it using HTML. You can turn a <dialog> element into a popover (<dialog popover> is perfectly valid) if you want to combine popover control with dialog semantics.
Typical use cases for the popover API include user-interactive elements like action menus, custom "toast" notifications, form element suggestions, content pickers, or teaching UI.
You can create popovers in two different ways:
Via a set of new HTML attributes. A simple popover with a toggle button can be created using the following code:
<button popovertarget="mypopover">Toggle the popover</button> <div id="mypopover" popover>Popover content</div>
Via a JavaScript API. For example, HTMLElement.togglePopover() can be used to toggle a popover between shown and hidden.
There are also new events to react to a popover being toggled, and CSS features to aid in styling popovers. All the new features are listed below.
See Using the popover API for a detailed guide to using this API.
popoverA global attribute that turns an element into a popover element; takes a popover state ("auto", "hint", or "manual") as its value.
popovertargetTurns a <button> or <input> element into a popover control button; takes the ID of the popover element to control as its value.
popovertargetactionSpecifies the action to be performed ("hide", "show", or "toggle") on the popover element being controlled by a control <button> or <input>.
::backdropThe ::backdrop pseudo-element is a full-screen element placed directly behind popover elements, allowing effects to be added to the page content behind the popover(s) if desired (for example blurring it out).
:popover-openThe :popover-open pseudo-class matches a popover element only when it is in the showing state — it can be used to style popover elements when they are showing.
ToggleEventRepresents an event notifying the user when a popover element's state toggles between showing and hidden. It is the event object for the beforetoggle and toggle events, which fire on popovers when their state changes.
HTMLElement.popoverGets and sets an element's popover state via JavaScript ("auto", "hint", or "manual"), and can be used for feature detection. Reflects the value of the popover global HTML attribute.
Gets and sets the popover element being controlled by the control button. The JavaScript equivalent of the popovertarget HTML attribute.
Gets and sets the action to be performed ("hide", "show", or "toggle") on the popover element being controlled by the control button. Reflects the value of the popovertargetaction HTML attribute.
HTMLElement.hidePopover()Hides a popover element by removing it from the top layer and styling it with display: none.
HTMLElement.showPopover()Shows a popover element by adding it to the top layer.
HTMLElement.togglePopover()Toggles a popover element between the showing and hidden states.
HTMLElement.beforetoggle eventFired just before a popover element's state changes between showing and hidden, or vice versa. Can be used to prevent a popover from opening, or to update other elements that need to be triggered by popover state.
HTMLElement.toggle eventFired just after a popover element's state changes between showing and hidden, or vice versa.
See our Popover API examples landing page to access the full collection of MDN popover examples.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Popover_API |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 18.317–18.3On iOS and iPadOS, popovers are not dismissed when the user taps outside of the popover area, see bug 267688. |
23.0 | 114 | 18.317–18.3On iOS and iPadOS, popovers are not dismissed when the user taps outside of the popover area, see bug 267688. |
hint |
133 | 133 | No | 118 | No | 133 | No | 88 | No | No | 133 | No |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Popover_API |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Popover_API |
114 | 114 | 125 | 100 | 17 | 114 | 125 | 76 | 17 | 23.0 | 114 | 17 |
popover HTML global attributepopovertarget HTML attributepopovertargetaction HTML attribute::backdrop CSS pseudo-element:popover-open CSS pseudo-class
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Popover_API