Forms & Controls

method="dialog"

Build a form with the HTML form generator

When submitted inside a dialog, closes that dialog instead of sending a network request. The submitter value can become the dialog returnValue; normal validation can prevent submission. Form submission method; formmethod on a submitter can override it. Missing or invalid method defaults to get.

Formal Syntax & Structure

html syntaxhtml
method="dialog"

Parameters & Attributes

NameTypeDescription
methodkeywordWhen submitted inside a dialog, closes that dialog instead of sending a network request. The submitter value can become the dialog returnValue; normal validation can prevent submission.

Working Example

Example Snippethtml
<button id="launch">Open</button><dialog id="notice" aria-label="Confirm">  <form method="dialog">    <button value="ok">OK</button>  </form></dialog><script>  document.getElementById("launch").onclick=()=>document.getElementById("notice").showModal();</script>
HTML Reference