Interactive Elements

closedby="any"

Allows a dialog to close through light dismissal, platform close requests and explicit developer-provided actions. Use only when clicking outside should dismiss the current interaction. On dialog; missing or invalid defaults to auto, whose effective behavior depends on modal versus nonmodal opening. Check support independently from dialog itself.

Formal Syntax & Structure

html syntaxhtml
closedby="any"

Parameters & Attributes

NameTypeDescription
closedbykeywordAllows a dialog to close through light dismissal, platform close requests and explicit developer-provided actions. Use only when clicking outside should dismiss the current interaction.

Working Example

Example Snippethtml
<button id="launch">Open dialog</button><dialog id="notice" closedby="any" aria-labelledby="heading">  <h2 id="heading">Notice</h2>  <form method="dialog">    <button>Close</button>  </form></dialog><script>  document.getElementById("launch").addEventListener("click",()=>document.getElementById("notice").showModal());</script>
HTML Reference