HTML popover Attribute

Beginner
6 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The popover global attribute marks an element as a popover — content that can float above the page in the browser top layer. Pair it with showPopover() / hidePopover() or a button that uses popovertarget.

Use popovers for menus, teaching tips, and lightweight overlays. Prefer <dialog> when you need a true modal dialog with focus-trapping semantics. For background UI, consider inert.

Widely available · 2024+.

Supported in current Chrome, Edge, Firefox, and Safari. Feature-detect ("popover" in HTMLElement.prototype) for older browsers.

hint is newer.

Prefer auto / manual for critical UI. Use hint only as enhancement where supported.

HTML Syntax

syntax.html
<element popover [="auto|manual|hint"]>

Empty value or auto means auto. Give the popover an id so buttons can target it with popovertarget.

Attribute Values

ValueDescriptionTry it
auto / emptyLight-dismiss; closes on outside click or EscapeTry it
manualStays until hidden via script or matching toggleTry it
hintNon-disruptive hint popover (newer support)Try it

Live Preview

Toggle an auto popover with a button. Click outside or press Escape to dismiss.

The panel uses popover (auto). Unsupported browsers show a fallback note.

Result

Hello popover

Click outside or press Escape to close.

popover (auto)

HTML Examples

Example 1 — Auto Popover with popovertarget

The simplest pattern: a button targets a popover by id.

HTML
<button type="button" popovertarget="tips">Tips</button>

<div id="tips" popover>
  <p>Auto popovers close on outside click.</p>
  <button type="button" popovertarget="tips" popovertargetaction="hide">Close</button>
</div>
Try It Yourself

How It Works

  1. Add popover (auto by default) to the overlay element.
  2. Point popovertarget at the popover’s id.
  3. Light dismiss closes on outside click or Escape.
  4. Optional hide action with popovertargetaction="hide".

Example 2 — Manual Popover

Keep a dock or panel open until the user toggles it off.

HTML
<button type="button" popovertarget="dock" popovertargetaction="toggle">Dock</button>

<aside id="dock" popover="manual">
  <p>Manual popover stays until toggled off.</p>
</aside>
Try It Yourself

How It Works

  1. Set popover="manual" to opt out of light dismiss.
  2. Use toggle action or call togglePopover() in script.
  3. Outside clicks do not close manual popovers.
  4. Provide an obvious close control for accessibility.

Example 3 — hint and showPopover()

Use hint for non-disruptive tips where supported, or drive popovers from script.

HTML
<button type="button" id="save">Save</button>
<div id="toast" popover="manual">Saved!</div>
<div id="tip" popover="hint">Tip: press Ctrl+S</div>
<script>
  document.getElementById("save").onclick = () => {
    const toast = document.getElementById("toast");
    toast.showPopover();
    setTimeout(() => toast.hidePopover(), 1500);
  };
</script>
Try It Yourself

How It Works

  1. showPopover / hidePopover control visibility from script.
  2. manual fits transient toasts you dismiss on a timer.
  3. hint is for non-modal tips that should not fight auto popovers.
  4. Feature-detect before relying on hint in production.

Edge Cases & Pitfalls

Top-layer promotion is free — focus and positioning are still your job.

focus

Manage focus thoughtfully

Move focus into the popover when opened for keyboard users, and restore it on close.

css

Positioning is still your job

The attribute promotes to the top layer; place the popover with CSS (anchor positioning or absolute offsets).

support

Feature-detect older browsers

Offer a non-popover fallback when HTMLElement.prototype.showPopover is missing.

hint

hint support varies

Keep critical UI on auto/manual until hint is universally safe for your audience.

Browser Support

popover is an HTML attribute for browsers. It is not a Node.js, Deno, or Bun API.

✓ Widely available · 2024+

popover

Modern Chromium, Firefox, and Safari support the Popover API. Detect before shipping critical UI. hint is newer.

92% Global support (approx.)
Google Chrome 114+ · hint newer
Full support
Mozilla Firefox 125+
Full support
Apple Safari 17+
Full support
Microsoft Edge 114+
Full support
Opera 100+
Full support
Samsung Internet 23+
Full support
Internet Explorer No support
Not supported
popover Modern browsers

Bottom line: Safe for progressive enhancement. Keep a fallback for older browsers. Treat hint as optional.

Key Takeaways

  • Role: promote UI into the top-layer popover stack.
  • Values: auto (default), manual, hint.
  • Controls: popovertarget or showPopover().
  • Not dialog: use <dialog> for true modals.

One line: popover floats UI in the top layer — auto dismisses, manual stays, hint tips softly.

Frequently Asked Questions

It turns an element into a popover that can appear in the browser top layer. Values include auto (light-dismiss), manual (script-controlled), and hint (non-disruptive hints where supported).
Call element.showPopover() / hidePopover() / togglePopover(), or use a button with popovertarget pointing at the popover’s id.
auto popovers close on outside click or Escape and usually allow only one auto popover at a time. manual popovers stay until you hide them in script (or with a matching toggle).
hint is for non-modal, non-light-dismiss teaching tips that should not steal the auto popover stack. Support is newer — feature-detect before relying on it.
No. dialog is for modal or non-modal dialogs with richer dialog semantics. popover is for lightweight overlays like menus and tooltips.
auto/manual are widely available in modern Chromium, Firefox, and Safari. Treat hint as progressive enhancement.

Next: popovertarget

Point a button at a popover id to open or close it without script.

popovertarget tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful