Favorites

DOM HTMLElement.showPopover() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
HTMLElement.showPopover()
DOM HTMLElement MethodThis method is supported by all modern browsers.
Updated 28th November 2026

The showPopover() method opens an element that has the popover attribute. hidePopover() and togglePopover() close or toggle it.

Description

The showPopover() method shows an element that has the popover attribute, placing it in the top layer above other content. hidePopover() hides it and togglePopover() switches it. Popovers with popover="auto" close when the user clicks outside or presses Escape.

Often no JavaScript is needed at all: a button with popovertarget opens and closes a popover declaratively. The toggle event reports when it opens or closes.

Calling showPopover() on a popover that's already open, or on an element without the popover attribute, throws an error, so check the :popover-open state with matches() first, or use togglePopover(). Popovers are often positioned next to their trigger with CSS anchor positioning.

Syntax

element.showPopover()
element.hidePopover()
element.togglePopover()

Return Value

None for showPopover() and hidePopover(); togglePopover() returns true if the popover is now open.

Example

<button id="show" type="button">Show tip</button>
<div id="tip" popover>Popovers close when you click outside.</div>
const tip = document.getElementById('tip');
tip.addEventListener('toggle', e => console.log('popover is now', e.newState));
document.getElementById('show').addEventListener('click', () => tip.showPopover());

Browser Support

The following information will show you the current browser support for the HTMLElement.showPopover() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee