The Popover API gives any element popover (auto or manual). The browser puts it on the top layer, handles light dismiss (click outside, Escape for auto), and manages a single auto popover at a time unless you stack manuals. A button with popovertarget="menu" opens it without addEventListener. You still style it; you do not reinvent click-outside.

auto versus manual versus dialog

html
<button popovertarget="m">Menu</button>
<div id="m" popover>
  <button>Item</button>
</div>

popover=auto (the default) light-dismisses and closes others. popover=manual is for persistent teaching UI you close in code (hidePopover()). <dialog> is for modal or dialog-shaped interactions with a backdrop that blocks the page (showModal()). A popover does not inert the rest of the document the same way. If you need a focus trap that blocks the app, use dialog. If you need a menu, popover + keyboard (or a component library on top) is the new baseline.

::backdrop exists for popovers in supporting browsers. Top layer means z-index: 9999 wars can end.

Accessibility

A popover is not automatically a menu. Set roles (menu / listbox) and roving tabindex, or use a library. Invoker relationships help some AT. Focus: opening should move focus in; closing should restore. Test this; native is better than homemade but not a complete APG widget.

Anchor positioning + popover is the CSS pairing for anchored menus.

Forms and nested buttons

A popover inside a <form> has submit pitfalls. command/commandfor invokers are evolving; read current HTML for popovertargetaction. Polyfills exist for older browsers.

Read MDN's Popover API and the dialog element comparison. Then remove a mousedown document listener from a dropdown. If you needed modal lock, you reached for the wrong API. Popover is top-layer + dismiss. Dialog is modal. Mixing the words is how you get a menu that traps the whole app.