Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
Reference / HTML

<dialog>

Native HTML5 modal and popup dialog element with built-in backdrop support, focus trapping, and Esc key dismissal.

Syntax
<dialog id="my-modal">...</dialog>

Examples

Opening accessible native modal
<dialog id="auth-dialog">
  <form method="dialog">
    <h2>Confirm Action</h2>
    <button value="cancel">Cancel</button>
    <button value="confirm">Confirm</button>
  </form>
</dialog>

<script>
  const d = document.getElementById('auth-dialog');
  d.showModal(); // Accessible backdrop and focus trap
</script>
showModal() provides native top-layer rendering and backdrop pseudoclass ::backdrop.