HTMLElement: showPopover() method

Baseline 2024
Newly available

Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The showPopover() method of the HTMLElement interface shows a popover element (i.e., one that has a valid popover attribute) by adding it to the top layer.

When showPopover() is called on an element with the popover attribute that is currently hidden, a beforetoggle event will be fired, followed by the popover showing, and then the toggle event firing. If the element is already showing, an error will be thrown.

Syntax

js
showPopover()
showPopover(options)

Parameters

options Optional

An object that can contain the following properties:

source Optional

An HTMLElement reference; programmatically defines the invoker of the popover associated with the show action, that is, its control element. Establishing a relationship between a popover and its invoker using the source option has two useful effects:

  • The browser places the popover in a logical position in the keyboard focus navigation order when shown. This makes the popover more accessible to keyboard users (see also Popover accessibility features).
  • The browser creates an implicit anchor reference between the two, making it very convenient to position popovers relative to their controls using CSS anchor positioning. See Popover anchor positioning for more details.

Return value

None (undefined).

Exceptions

InvalidStateError DOMException

Thrown if the popover is already showing.

Examples

The following example provides functionality to show a popover by pressing a particular key on the keyboard.

First, some HTML:

html
<div id="mypopover" popover>
  <h2>Help!</h2>

  <p>You can use the following commands to control the app</p>

  <ul>
    <li>Press <ins>C</ins> to order cheese</li>
    <li>Press <ins>T</ins> to order tofu</li>
    <li>Press <ins>B</ins> to order bacon</li>
  </ul>
  <hr />
  <ul>
    <li>Say "Service" to summon the robot waiter to take your order</li>
    <li>Say "Escape" to engage the ejector seat</li>
  </ul>
</div>

And now the JavaScript to wire up the functionality:

js
const popover = document.getElementById("mypopover");

document.addEventListener("keydown", (event) => {
  if (event.key === "h") {
    popover.showPopover();
  }
});

Specifications

Specification
HTML
# dom-showpopover

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
showPopover
Chrome – Full support
Chrome 114 (Release date: 2023-05-30)
footnote Full support
Edge – Full support
Edge 114 (Release date: 2023-06-02)
footnote Full support
Firefox – Full support
Firefox 125 (Release date: 2024-04-16)
footnote Full support
Opera – Full support
Opera 100 (Release date: 2023-06-29)
footnote Full support
Safari – Full support
Safari 17 (Release date: 2023-09-18)
footnote Full support
Chrome Android – Full support
Chrome Android 114 (Release date: 2023-05-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 125 (Release date: 2024-04-16)
footnote Full support
Opera Android – Full support
Opera Android 76 (Release date: 2023-06-26)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17 (Release date: 2023-09-18)
footnote Full support
Samsung Internet – Full support
Samsung Internet 23 (Release date: 2023-10-18)
footnote Full support
WebView Android – Full support
WebView Android 114 (Release date: 2023-05-30)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17 (Release date: 2023-09-18)
footnote Full support
options.source parameter
Chrome – Partial support
Chrome 133 – 136 (Release date: 2025-02-04)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
Chrome – Full support
Chrome 137 (Release date: 2025-05-27)
footnote Full support
Edge – Partial support
Edge 133 – 136 (Release date: 2025-02-06)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
Edge – Full support
Edge 137 (Release date: 2025-05-29)
footnote Full support
Firefox – Partial support
Firefox 141 – 143 (Release date: 2025-07-22)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 1984004.
Firefox – Full support
Firefox 144 (Release date: 2025-10-14)
footnote Full support
Opera – Partial support
Opera 118 – 120 (Release date: 2025-04-15)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
Opera – Full support
Opera 121 (Release date: 2025-08-27)
footnote Full support
Safari – Partial support
Safari 18.4 – 18.6 (Release date: 2025-03-31)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 286575.
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Partial support
Chrome Android 133 – 136 (Release date: 2025-02-04)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
Chrome Android – Full support
Chrome Android 137 (Release date: 2025-05-27)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 141 – 143 (Release date: 2025-07-22)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 1984004.
Firefox for Android – Full support
Firefox for Android 144 (Release date: 2025-10-14)
footnote Full support
Opera Android – Partial support
Opera Android 88 – 89 (Release date: 2025-03-19)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
Opera Android – Full support
Opera Android 90 (Release date: 2025-06-18)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 18.4 – 18.6 (Release date: 2025-03-31)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 286575.
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
WebView Android – Partial support
WebView Android 133 – 136 (Release date: 2025-02-04)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 383343310.
WebView Android – Full support
WebView Android 137 (Release date: 2025-05-27)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 18.4 – 18.6 (Release date: 2025-03-31)
footnote Partial support
footnote When using this option, the focus order doesn't change, so the popover does not become the next focus element. See bug 286575.
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support
Implicit anchor reference via source
Chrome – Full support
Chrome 133 (Release date: 2025-02-04)
footnote Full support
Edge – Full support
Edge 133 (Release date: 2025-02-06)
footnote Full support
Firefox – Full support
Firefox 147 (Release date: 2026-01-13)
footnote Full support
Opera – Full support
Opera 118 (Release date: 2025-04-15)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 133 (Release date: 2025-02-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 147 (Release date: 2026-01-13)
footnote Full support
Opera Android – Full support
Opera Android 88 (Release date: 2025-03-19)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 133 (Release date: 2025-02-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

See also