<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>HTML on Simon&#39;s Blog</title>
    <link>https://blog.simon-hu.org/tags/html/</link>
    <description>Recent content in HTML on Simon&#39;s Blog</description>
    <image>
      <title>Simon&#39;s Blog</title>
      <url>https://blog.simon-hu.org/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://blog.simon-hu.org/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.148.1</generator>
    <language>en</language>
    <lastBuildDate>Thu, 12 Jun 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.simon-hu.org/tags/html/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>[Note] Popover vs Dialog Web-API</title>
      <link>https://blog.simon-hu.org/posts/2025/06---june/2025-06-12-popover-api/</link>
      <pubDate>Thu, 12 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://blog.simon-hu.org/posts/2025/06---june/2025-06-12-popover-api/</guid>
      <description>&lt;h2 id=&#34;demonstration&#34;&gt;&lt;strong&gt;Demonstration&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img alt=&#34;2025-06-12T115847&#34; loading=&#34;lazy&#34; src=&#34;https://blog.simon-hu.org/posts/2025/06---june/2025-06-12-popover-api/2025-06-12T115847.gif&#34;&gt;&lt;/p&gt;
&lt;p&gt;(in browser that does NOT support the anchor position API: &lt;a href=&#34;2025-06-12T115714.gif&#34;&gt;2025-06-12T115714.gif&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;(the source code of the above can be found at: &lt;a href=&#34;index-dialog-popover.html.zip&#34;&gt;index-dialog-popover.html.zip&lt;/a&gt;)&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;differences&#34;&gt;Differences&lt;/h2&gt;
&lt;h3 id=&#34;modal-vs-non-modal-behaviour&#34;&gt;Modal vs Non-Modal Behaviour&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The Popover API always creates &lt;strong&gt;non-modal overlays&lt;/strong&gt;. This means users can continue interacting with the rest of the page even when a popover is open&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; element supports &lt;strong&gt;both modal and non-modal&lt;/strong&gt; dialogs. A modal dialog prevents interaction with the rest of the page until it is dismissed, making it suitable for critical interactions or required user input&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;implementation&#34;&gt;Implementation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The Popover API is an &lt;strong&gt;attribute&lt;/strong&gt; (&lt;code&gt;popover&lt;/code&gt;) that can be added to any HTML element, making it flexible for various UI needs&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; is a dedicated HTML element with a &lt;strong&gt;JavaScript API&lt;/strong&gt; for showing and hiding dialogs, and can also be combined with the popover attribute if needed&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;positioning&#34;&gt;Positioning&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Popovers are typically anchored to a trigger element and support &lt;strong&gt;implicit anchor positioning&lt;/strong&gt; via the &lt;strong&gt;&lt;a href=&#34;https://developer.chrome.com/blog/rfc-customizable-select&#34;&gt;anchor position api&lt;/a&gt;&lt;/strong&gt;, making them ideal for context-sensitive overlays.&lt;/li&gt;
&lt;li&gt;Dialogs are generally centered or &lt;strong&gt;fixed in the viewport&lt;/strong&gt; and do not have built-in anchor positioning&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;usage-and-typical-scenarios&#34;&gt;Usage and Typical Scenarios&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Use the Popover API for lightweight, contextual UI components such as tooltips, dropdown menus, teaching bubbles, or notifications—where the user should not be blocked from interacting with the rest of the page.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; for modal interactions that require user attention and input before proceeding, such as confirmation dialogs, forms, or alerts&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;reference&#34;&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.chrome.com/blog/introducing-popover-api&#34;&gt;https://developer.chrome.com/blog/introducing-popover-api&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.chrome.com/docs/css-ui/anchor-positioning-api&#34;&gt;https://developer.chrome.com/docs/css-ui/anchor-positioning-api&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/API/Popover_API&#34;&gt;https://developer.mozilla.org/en-US/docs/Web/API/Popover_API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog&#34;&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
  </channel>
</rss>
