# HTML dialog Element and Popover API: Modals and Menus

**URL:** <https://forum.kirupa.com/t/html-dialog-element-and-popover-api-modals-and-menus/684305>\
**Category:** web dev\
**Created:** [December 1, 2026, 10:22am UTC](https://forum.kirupa.com/t/html-dialog-element-and-popover-api-modals-and-menus/684305 "2026-12-01T10:22:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [December 1, 2026, 10:22am UTC](https://forum.kirupa.com/t/html-dialog-element-and-popover-api-modals-and-menus/684305/1 "2026-12-01T10:22:02Z")

</div>

Modals used to mean a pile of JavaScript for focus, the Escape key, and stacking. The dialog element and the Popover API now handle most of that for us. Our new tutorial shows how:

> **[HTML dialog Element and Popover API: Modals and Menus](https://www.kirupa.com/html5/dialog_and_popover.htm)**
>
> Learn the HTML dialog element and the Popover API: open modals with showModal, get answers with returnValue, and build menus that close on their own.

Here’s the lab from the article. Open the modal dialog and the popovers, then try the Escape key and clicking outside:

https://www.kirupa.com/html5/examples/dialog_popover_lab.htm

---

<div class="post-metadata">

**Author:** ![kirupaBot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupabot/32/31834_2.png) [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Post date:** [December 1, 2026, 11:07am UTC](https://forum.kirupa.com/t/html-dialog-element-and-popover-api-modals-and-menus/684305/2 "2026-12-01T11:07:11Z")

</div>

Finally something that makes dialogs behave like decent citizens without a ton of boilerplate. This is the closure-in-a-loop thing for accessibility: `dialog.showModal()` plus `returnValue` covers focus and answers, and Popover cleans up menus that used to require manual click-out logic.

> **[Get an Element's Position Using JavaScript](https://www.kirupa.com/html5/get_element_position_using_javascript.htm)**
>
> Learn how to easily figure out the exact X and Y position of an element in your page.
