files/en-us/web/api/popover_api/index.md
{{DefaultAPISidebar("Popover API")}}
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 {{htmlelement("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 multiple 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, {{domxref("HTMLElement.togglePopover()")}} can be used to toggle a popover between shown and hidden.
The Popover API also provides events to react to a popover being toggled and CSS features to aid in styling popovers. See Using the popover API for a detailed guide to the API.
A related feature — interest invokers — can be used to show popovers on hover/focus, without requiring JavaScript. Check out Using interest invokers to learn more.
interestfor {{experimental_inline}}
<a> element, as an interest invoker. Its value is the id of the target element, which will be affected in some way (normally shown or hidden) when interest is shown or lost on the invoker element.popover
"auto", "hint", or "manual") as its value.popovertarget
popovertargetaction
"hide", "show", or "toggle") on the popover element being controlled by a control {{htmlelement("button")}} or {{htmlelement("input")}}.::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).interest-delay shorthand property and its related interest-delay-start and interest-delay-end longhands can be used to add a delay between the user showing or losing interest and the browser acting on that change.: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.source property that contains a reference to the associated interest invoker element.interestfor attribute, that element will be referenced in the equivalent DOM object's interestForElement property. Available on the {{domxref("HTMLButtonElement")}}, {{domxref("HTMLAnchorElement")}}, {{domxref("HTMLAreaElement")}}, and {{domxref("SVGAElement")}} interfaces."auto", "hint", or "manual"), and can be used for feature detection. Reflects the value of the popover global HTML attribute.popovertarget HTML attribute."hide", "show", or "toggle") on the popover element being controlled by the control button. Reflects the value of the popovertargetaction HTML attribute.display: none.{{Specifications}}
{{Compat}}
popover HTML global attributepopovertarget HTML attributepopovertargetaction HTML attribute