Native Popover Element with HTML

The HTML Popover API builds tooltips, dropdowns and overlays without a JavaScript library. How to use it, what it returns and where browsers support it.

Building overlay UI elements like tooltips and dropdowns has always required complex JavaScript libraries. The new HTML Popover API changes this with native browser support for floating elements.

Update: Corrected Browser Support and Return Values

An earlier edit of this post said the Popover API was Baseline Widely available since April 2025. It is Baseline Newly available since January 2025, when Safari on iOS 18.3 started closing popovers on a tap outside them.

togglePopover() also returns a boolean rather than undefined: true if the popover is open after the call. Both statements below are now corrected. Sources: webstatus.dev and MDN.

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

The Popover API introduces a new popover attribute that transforms any HTML element into a floating overlay.

The browser handles all the complex positioning, stacking order, and focus management automatically. This means we can create interactive UI elements without wrestling with z-index, click-outside handling, or managing focus states.

index.html
<button popovertarget="info">Toggle Popover</button>
<div id="info" popover>
<p>Popover content appears above other elements</p>
</div>

We can control popovers through two modes: auto and manual

Auto popovers dismiss themselves when clicking outside or when another auto popover opens, perfect for simple tooltips or dropdowns. Manual popovers give us more control over their behavior, useful for complex dialogs or multi-step flows.

The JavaScript API provides three methods to control popovers programmatically: showPopover(), hidePopover(), and togglePopover()

These methods execute synchronously. showPopover() and hidePopover() return undefined, while togglePopover() returns true if the popover is open after the call and false otherwise. The API also provides the :popover-open CSS pseudo-class for styling popovers based on their visibility state.

The Popover API represents a significant step forward in web platform capabilities. Instead of relying on complex positioning libraries or managing overlay states manually, we now have a native solution that handles these challenges elegantly. This means simpler code, better performance, and improved accessibility out of the box.

The Popover API is Baseline Newly Available (since January 2025) and supported across all major browsers, including Chrome 114+, Firefox 125+, Safari 17+ and Safari on iOS 18.3+. It’s the standard way to create overlay UI elements on the web.


Trevor I. Lasn

Trevor I. Lasn

Tech executive with over a decade of experience programming and building products. Building 0xinsider.com, ceodumps.com and whiteheap.com.



Related Articles

Check out these related articles that might be useful for you. They cover similar topics and provide additional insights.

CSS
3 min read

The new pseudo-classes :user-valid and :user-invalid give us a smarter way to style form validation states based on user interaction

Dec 12, 2024
Read article
Web performance
3 min read

Set loading=lazy on an iframe and the browser waits to load it until the reader scrolls near. Before-and-after code, the bandwidth saved and browser support.

Sep 13, 2024
Read article
CSS
3 min read

The ::details-content pseudo-element lets you style the expandable content of details elements separately from the summary, no divs needed.

Nov 11, 2025
Read article
HTML
3 min read

Discover how the HTML details element can replace your JavaScript accordions and why it might be better than your current solution

Dec 10, 2024
Read article
Web performance
9 min read

How the Speculation Rules API improves web performance by prefetching and prerendering future navigations

Sep 15, 2024
Read article
Web performance
3 min read

rel=modulepreload fetches, parses and compiles an ES module before a script imports it. How to use it, and why each module in the graph needs its own link.

Dec 4, 2024
Read article
HTML
3 min read

The <search> element wraps a search form or filter controls so browsers and screen readers know their purpose. When to use it, with input type=search examples.

Dec 2, 2024
Read article
CSS
4 min read

Style connected UI with the :interest-source and :interest-target pseudo-classes. Interactive examples of tooltips, forms and navigation without JavaScript.

Nov 12, 2025
Read article
Web performance
4 min read

Using link rel='preconnect' can improve your website's performance by reducing connection setup times to key external domains.

Sep 13, 2024
Read article

This article was originally published on https://www.trevorlasn.com/blog/native-popover-with-html. It was written by a human and polished using grammar tools for clarity.