<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhishek Ojha on Medium]]></title>
        <description><![CDATA[Stories by Abhishek Ojha on Medium]]></description>
        <link>https://medium.com/@abhishekojha?source=rss-dfcc6b21455d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p1uvrYQawDFWOF4m.</url>
            <title>Stories by Abhishek Ojha on Medium</title>
            <link>https://medium.com/@abhishekojha?source=rss-dfcc6b21455d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:45:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhishekojha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How React Renders: A Beginner Friendly Guide to the Rendering Engine]]></title>
            <link>https://medium.com/@abhishekojha/how-react-renders-a-beginner-friendly-guide-to-the-rendering-engine-95d5be9a4b24?source=rss-dfcc6b21455d------2</link>
            <guid isPermaLink="false">https://medium.com/p/95d5be9a4b24</guid>
            <dc:creator><![CDATA[Abhishek Ojha]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 23:04:29 GMT</pubDate>
            <atom:updated>2025-12-07T23:04:29.065Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How does React actually render the UI?</strong></p><p>You write some JSX, click a button, state changes, and the UI updates. It feels like magic. But behind that magic is a systematic process designed for performance and scalability.</p><p>In this article, let’s break down how React renders in a simple, beginner-friendly way, without digging too deep into internal complexity. Whether you are just starting out or trying to understand the basics better, this will help.</p><h3>What Does &quot;Rendering&quot; Mean?</h3><p>In simple terms:</p><p><strong>Rendering is the process of converting your React components into real HTML elements inside the browser.</strong></p><p>For example:</p><pre>function App() {<br>  return &lt;h1&gt;Hello World&lt;/h1&gt;;<br>}</pre><p>The browser cannot understand JSX. React takes this component and eventually turns it into an h1 element in the DOM.</p><p>To understand how, let’s go step by step.</p><h3>The Core Idea Behind React</h3><p>React is built around three foundational ideas:</p><h3>1. UI is Derived from State</h3><p>Your UI should be a direct reflection of your data. Whenever your state changes, the UI should change automatically.</p><h3>2. Declarative Programming</h3><p>You describe what the UI should look like, not how to update it. If the state changes, React figures out the updates for you.</p><h3>3. Efficient DOM Updates</h3><p>Directly updating the DOM frequently is slow. React updates only the parts that change, instead of reloading everything.</p><h3>The Rendering Engine in Action</h3><p>React does not update the browser directly when you return JSX. It first creates a structure called the <strong>Virtual DOM</strong>.</p><p>Think of it like a blueprint.</p><h3>Step 1: Creating a Virtual DOM</h3><p>When your component renders, React builds a virtual representation of the UI in memory. It creates a tree-like structure that describes what should appear on the screen.</p><p>For example, the Virtual DOM might look like this:</p><pre>App<br> └── h1 (text: &quot;Hello World&quot;)</pre><p>This is not the actual DOM. It’s just an internal representation that React uses to know what to render.</p><h3>Step 2: Re-rendering When State Changes</h3><p>When you call setState or props change:</p><ol><li>React runs your component again</li><li>Creates a new Virtual DOM tree</li><li>Compares the new tree with the previous one</li></ol><p>This comparison process is called <strong>reconciliation</strong>.</p><p>The purpose is to find what changed.</p><h3>The Diffing Algorithm</h3><p>React uses an optimized algorithm to compare the two Virtual DOM trees. Instead of checking every element exhaustively, it uses smart rules to find changes quickly.</p><p>For example:</p><p>Old Virtual DOM:</p><pre>&lt;h1&gt;Hello World&lt;/h1&gt;</pre><p>New Virtual DOM:</p><pre>&lt;h1&gt;Hello React&lt;/h1&gt;</pre><p>React identifies that only the text changed, so it updates just the text in the real DOM, rather than replacing the entire element.</p><p>This is much faster than rebuilding the whole UI.</p><h3>Updating the Real DOM</h3><p>Once React knows what changed, it applies those changes to the <strong>real DOM</strong>. This is known as the <strong>commit phase</strong>.</p><p>Only the necessary parts are updated, which is why React apps feel fast and responsive even with frequent updates.</p><h3>Introducing React Fiber</h3><p>Modern versions of React use a new rendering engine called <strong>Fiber</strong>.</p><p>Fiber was introduced to make rendering more flexible and efficient. The idea is simple: instead of doing all work in one go, Fiber breaks the rendering into smaller units.</p><p>This allows React to:</p><ul><li>pause rendering work</li><li>resume later</li><li>prioritize important updates (like user typing)</li><li>keep the UI responsive under load</li></ul><p>Fiber is like a smart scheduler that manages how and when rendering happens.</p><h3>Why Virtual DOM Matters</h3><p>The Virtual DOM is central to React’s performance.</p><p>Imagine a list with 100 items. If one changes, updating all 100 in the real DOM would be slow. With the Virtual DOM, React identifies exactly which item changed and updates only that.</p><p>This approach scales well for large applications.</p><h3>Example: Re-rendering in React</h3><p>Here’s a simple example to illustrate how rendering works in practice:</p><pre>function Counter() {<br>  const [count, setCount] = useState(0);</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>        Click<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Every time you click the button:</p><ol><li>setCount updates the state</li><li>Component re-renders</li><li>React builds a new Virtual DOM</li><li>React compares it with the previous one</li><li>Only the text inside &lt;p&gt; is updated</li></ol><p>Even though the whole component re-renders in code, only the necessary change is applied to the DOM.</p><h3>Render Phase vs Commit Phase</h3><p>React does work in two major steps:</p><h3>Render Phase</h3><p>React prepares the new Virtual DOM, calculates changes, and decides what needs to be updated. This phase is pure calculation and doesn’t touch the real DOM.</p><h3>Commit Phase</h3><p>React applies the calculated updates to the browser DOM. This is the point where the UI changes visually.</p><p>Separating these phases helps React stay performance-friendly.</p><h3>Common Misunderstanding</h3><p>A common misconception is</p><p><strong>“React updates the DOM on every re-render.”</strong></p><p>This is not true.<br> React re-renders components in memory (Virtual DOM), but updates to the real DOM happen only after comparing changes.</p><p>This is the core reason why React performs well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95d5be9a4b24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Client-Side Rendering vs Server-Side Rendering: A Modern Guide for Web Developers]]></title>
            <link>https://medium.com/@abhishekojha/client-side-rendering-vs-server-side-rendering-a-modern-guide-for-web-developers-6d30a2d5cc58?source=rss-dfcc6b21455d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d30a2d5cc58</guid>
            <dc:creator><![CDATA[Abhishek Ojha]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 10:46:05 GMT</pubDate>
            <atom:updated>2025-12-04T10:46:05.055Z</atom:updated>
            <content:encoded><![CDATA[<p>Rendering defines how a website delivers content to users. Whether a page is built using Client-Side Rendering (CSR) or Server-Side Rendering (SSR) has a direct impact on page speed, device performance, and search engine visibility.</p><p>Both approaches are widely used in modern development, but they solve different types of problems. This blog explains how each method works, what advantages and limitations they have, and how to choose the right one for your project.</p><h3>Client-Side Rendering (CSR)</h3><p>Client-side rendering shifts the responsibility of building the user interface from the server to the browser. The server returns a minimal HTML structure, and the browser downloads JavaScript to fetch data and render the UI dynamically.</p><p>This approach became popular with frameworks such as React, Vue, Angular, and Svelte, which allow websites to behave like application software.</p><h3>How CSR Works</h3><p>Browser → Server → Bare HTML → JavaScript Bundle → API Calls → UI Rendered</p><p>The application is initialized on the client. Once the JavaScript bundle loads, it fetches data and renders the UI.</p><h3>Advantages of CSR</h3><h4>Application-Like Experience</h4><p>Page transitions feel instant, without reloading the entire page. This creates a smooth experience similar to native desktop or mobile applications.</p><h4>Cleaner Backend Architecture</h4><p>The server acts as a data source through APIs. Most rendering and state management is handled in the frontend layer, helping to separate responsibilities clearly.</p><h4>Designed for Complex Interfaces</h4><p>CSR is well suited for products that need extensive client-side logic and dynamic UI, such as online editors, dashboards, data visualization tools, and real-time applications.</p><h3>Limitations of CSR</h3><h4>Slower Initial Load</h4><p>Users see a blank page until JavaScript loads and runs. This can negatively affect first impressions and perceived performance.</p><h4>SEO Challenges</h4><p>Because content is generated by JavaScript, search engines may not always index it effectively. While indexing of dynamic content has improved, it is still a factor for content-heavy websites.</p><h3>When to Use CSR</h3><p>Client-side rendering is a good fit when:</p><ul><li>The product behaves more like an application than a static website</li><li>The interface demands rich interaction</li><li>SEO is not the primary focus</li><li>Continuous navigation matters more than initial load speed</li></ul><p>Examples include digital design tools, online editors, project management boards, and dashboards.</p><h3>Server-Side Rendering (SSR)</h3><p>Server-side rendering builds a complete HTML page on the server and delivers it to the browser. This allows the user to view meaningful content immediately, without waiting for JavaScript execution.</p><p>SSR has historically been the default rendering approach for the web and is now widely supported through modern frameworks like Next.js, Remix, Nuxt, and Astro.</p><h3>How SSR Works</h3><p>Browser → Server → Database/API Query → Fully Rendered HTML → UI and Hydration</p><p>The server performs rendering work before the browser receives the page.</p><h3>Advantages of SSR</h3><h4>Fast First Contentful Paint</h4><p>The browser receives fully rendered HTML, which results in a faster initial load. Users can start reading or interacting with content immediately.</p><h4>Strong SEO Support</h4><p>Search engines can index content directly from the HTML response. SSR is ideal for content-first websites that rely on search visibility.</p><h4>Lower Device Load</h4><p>Rendering happens on the server, reducing the processing work required from the browser. This can be helpful for users on slower devices or weak network connections.</p><h3>Limitations of SSR</h3><h4>Higher Server Resource Usage</h4><p>Rendering complete pages for every request increases server load and can be resource-intensive at scale.</p><h4>Interaction Overhead</h4><p>Some dynamic interactions may require additional communication with the server, potentially slowing down the experience for certain features.</p><h3>When to Use SSR</h3><p>Server-side rendering is a strong choice when:</p><ul><li>Initial load performance matters</li><li>Search engine visibility is important</li><li>The site is content-focused rather than interaction-heavy</li><li>The interface does not depend on complex client-side logic</li></ul><p>Examples include e-commerce product pages, blogs, news websites, landing pages, and marketing websites.</p><h3>CSR vs SSR: Comparison</h3><p>Category: Client-Side Rendering Server-Side Rendering Initial load SlowerFasterInteractivity High-medium SEO, medium to low High server load Low HighNavigation Instant SPA-like Full or partial reload Best suited for Applications Content websites</p><h3>Making the Right Decision</h3><p>There is no single correct choice between CSR and SSR. The decision depends on the type of product being built and the goals of the experience.</p><p>If the objective is to create a highly interactive interface that behaves like an application, CSR is typically the better approach.</p><p>If the objective is to deliver content quickly with strong SEO, SSR is usually the right fit.</p><p>Modern frameworks allow hybrid rendering strategies that combine both methods. This makes it possible to use SSR for initial delivery and CSR for interactions where it matters most.</p><h3>Final Thoughts</h3><p>Rendering is a core architectural decision that influences how users experience performance and discover content. CSR focuses on interactivity and smooth navigation, while SSR emphasizes initial load speed and indexing.</p><p>Understanding how both approaches work will help you design web applications that balance user experience, performance, and technical complexity effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d30a2d5cc58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Theming at the Component Level in AEM: An Exploration of Approaches]]></title>
            <link>https://medium.com/@abhishekojha/custom-theming-at-the-component-level-in-aem-an-exploration-of-approaches-f3579d19e89d?source=rss-dfcc6b21455d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3579d19e89d</guid>
            <dc:creator><![CDATA[Abhishek Ojha]]></dc:creator>
            <pubDate>Fri, 07 Jun 2024 17:18:48 GMT</pubDate>
            <atom:updated>2024-07-29T06:02:19.924Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital landscape, personalizing user experience is more important than ever. One crucial aspect of personalization is theming, which allows users to enjoy a visually consistent and appealing interface. This blog will delve into a specific use case within Adobe Experience Manager (AEM) where theming needs to be applied at the component level rather than at the site level. This means the author needs to select a colour from the colour picker for each component, and each can have its own theme configuration, even if multiple instances of the same component are present on a page or across various microsites. We’ll explore two different approaches to achieve this: using JavaScript and using inline CSS variables.</p><h4>Use Case and Requirements</h4><p>There was the ask to have the ability to configure themes at the component level in AEM. This involves:</p><ol><li>Each component has its own set of theme configurations, including background colour, text colour, border colour, etc.</li><li>The ability to author a component multiple times on the same page, each with its own unique theme configuration,</li><li>Components are being utilized across various microsites, each with distinct theme configurations.</li><li>The author selects the theme colours directly from the authoring dialogue in AEM.</li></ol><p>Given these requirements, two primary approaches were explored:</p><h3>Approach 1: Using JavaScript</h3><p>In this approach, JavaScript is utilized to dynamically assign theme configurations to each component. Here’s a detailed breakdown:</p><h4>Steps:</h4><ol><li>The selected colour chosen by the author in the AEM authoring dialogue is added to the component’s DOM element through a data attribute. For example, the background colour might be passed as data-bg1=&quot;#000000&quot;.</li><li>JavaScript targets all elements containing these data attributes, representing the colour for a specific component.</li><li>A unique class name is dynamically generated by the JavaScript (e.g., bg1234) and assigned to each instance of the selected elements.</li><li>Logic is implemented to generate a CSS rule corresponding to the selected colour, which is then appended to the head section of the DOM.</li></ol><pre>function generateRandomClassName() {<br> const randomNumber = `${comp.className}-${Math.floor(Math.random() * 1000000)}`;<br> const uppercaseLetters = &#39;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#39;;<br> const lowercaseLetters = &#39;abcdefghijklmnopqrstuvwxyz&#39;;<br> const alphabet = uppercaseLetters + lowercaseLetters;<br> return randomNumber + alphabet.charAt(Math.floor(Math.random() * alphabet.length));<br> }</pre><pre>// Function to dynamically create CSS rule<br>// className is randomly created using above method<br>    function createCSSRule(className, styles) {<br>        let css = &#39;.&#39; + className + &#39; {&#39;;<br>        for (const property in styles) {<br>            if (styles.hasOwnProperty(property)) {<br>                css += property + &#39;:&#39; + styles[property] + &#39;;&#39;;<br>            }<br>        }<br>        css += &#39;}&#39;;<br>        return css;<br>    }</pre><pre>// Above returned rule will be attached to the &lt;style&gt; present in &lt;head&gt;<br>// section<br>styleTag.innerHTML += cssRule;</pre><p>This results in the following CSS rule being added to the head section:</p><pre>&lt;style&gt;<br>.bg1234 is random generated class<br>.bg1234 {<br>    --tableBG: #000000;<br>}<br>&lt;/style&gt;</pre><p>Now, the dynamically generated class (bg1234) is present on the component&#39;s element, making the colour variable (--tableBG) accessible to the element and its children. The desired theme is applied as follows:</p><pre>background-color: var(--tableBG, #000000);</pre><h4>Pros:</h4><ul><li>Avoids inline CSS, keeping the HTML clean.</li></ul><h4>Cons:</h4><ul><li>It requires more code and effort, especially when dealing with different themes for multiple components.</li><li>Potential flicker issues due to dynamic style insertion.</li><li>Performance might be impacted, leading to layout shifts and longer loading times.</li></ul><h3>Approach 2: Using Inline CSS Variables</h3><p>This approach leverages inline CSS variables to apply the selected theme configurations directly to each component.</p><h4>Steps:</h4><ol><li>In the AEM authoring dialogue, the author selects the desired colour.</li><li>AEM sends the author’s chosen colour code directly into the component’s inline style attribute as a CSS variable, such as --timelineTheme: #000000.</li><li>The frontend (FE) code then uses this variable (--timelineTheme) to apply the colour wherever it&#39;s needed in the component&#39;s styling.</li></ol><p>Example:</p><pre>&lt;div style=&quot;--timelineTheme: #000000;&quot;&gt;<br>    &lt;!-- Component content --&gt;<br>&lt;/div&gt;</pre><p>The CSS rule would then be:</p><pre>// in .scss<br>background-color: var(--timelineTheme, #000000);</pre><h4>Pros:</h4><ul><li>Minimal code and effort required.</li><li>Clean and rapid development process.</li><li>No observed performance impacts.</li><li>No flickering issues.</li></ul><h4>Cons:</h4><ul><li>The use of inline styles, which some developers might consider less ideal.</li></ul><h3>Real-World Examples</h3><p>During our analysis, we discovered several prominent websites utilizing the inline CSS variable approach, such as:</p><ul><li><a href="https://www.adobe.com/creativecloud.html">Adobe Creative Cloud</a></li><li><a href="https://github.com/">GitHub</a></li><li><a href="https://developers.google.com/">Google Developers</a></li><li><a href="https://web.dev/">web.dev</a></li><li><a href="https://learn.microsoft.com/en-us/">Microsoft Learn</a></li></ul><h3>Conclusion</h3><p>While both approaches are viable, Approach 2 using inline CSS variables is preferable for this use case. It offers a straightforward implementation with minimal performance impact, even when multiple instances of the component are present on the page. Approach 1, though avoiding inline CSS, introduces potential performance issues and requires more complex code, which can lead to flickering and longer loading times.</p><h4>Key Takeaways:</h4><ol><li><strong>Performance</strong>: Inline CSS variables do not trigger reflow, as only non-layout properties like background-color are updated.</li><li><strong>Ease of Implementation</strong>: Approach 2 is simpler and quicker to implement.</li><li><strong>Stability</strong>: There are no flickering issues with Approach 2, ensuring a smooth user experience.</li></ol><p>For developers facing similar theming requirements at the component level, the inline CSS variable approach is highly recommended for its efficiency and effectiveness.</p><p>From a practical standpoint, the simplicity and performance benefits of using inline CSS variables make this approach highly advantageous. It aligns well with modern web development practices by leveraging native browser capabilities without introducing unnecessary complexity. Moreover, the straightforward nature of inline CSS variables ensures that theme configurations are easily manageable within AEM, providing a seamless experience for authors who need to apply unique themes to various component instances efficiently.</p><p>By exploring these approaches, you can make informed decisions about implementing component-level theming in your projects, ensuring both performance and maintainability. From an AEM author’s perspective, selecting the theme colour directly in the authoring dialogue simplifies the process and provides a seamless and intuitive experience for applying unique themes to each component instance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3579d19e89d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the HTML Dialog Element: Enhancing User Interaction]]></title>
            <link>https://medium.com/@abhishekojha/exploring-the-html-dialog-element-enhancing-user-interactions-eab50e8e9946?source=rss-dfcc6b21455d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eab50e8e9946</guid>
            <dc:creator><![CDATA[Abhishek Ojha]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 03:54:51 GMT</pubDate>
            <atom:updated>2024-12-20T16:12:20.910Z</atom:updated>
            <content:encoded><![CDATA[<p>Introduction:<br>The field of web development is ever-evolving, constantly introducing new HTML elements to enhance user experience and interactivity. One such element that has gained significant attention is the HTML dialog element. In this comprehensive blog post, we will dive deep into the intricacies of the dialog element, explore its diverse range of use cases, and provide you with real-world code examples to help you get started.</p><p>Understanding the HTML Dialog Element:<br>The HTML dialog element serves as a powerful tool for creating interactive modal dialogs within web pages. It enables developers to showcase content that necessitates user interaction while temporarily pausing background interactions. Dialogs can be utilized for various purposes, including alerts, confirmations, prompts, and custom modal windows.</p><p>Basics of the Dialog Element:<br>To create a dialog element, you simply need to use the `&lt;dialog&gt;` tag. It acts as a container where you can place any desired content and easily style it to suit your needs. The dialog element has a single custom attribute that can be added to it, making it straightforward to implement.</p><pre>&lt;dialog&gt;<br>  &lt;!-- Modal/Dialog content. It can be any normal markup that a Modal/Dialog <br>    can have--&gt;<br>&lt;/dialog&gt;</pre><p>By default, the dialog element remains hidden unless you add the `open` attribute to it. This attribute allows you to control the visibility of the dialog.</p><pre>&lt;dialog open&gt;<br>  &lt;span&gt;with open attribute dialog is default in open state but it is not<br>    recommended as it does not provide all controls that show()/showModal() <br>    provides<br>&lt;/span&gt;<br>&lt;/dialog&gt;</pre><p>However, it is recommended to use JavaScript methods like `show()` and `showModal()` to open the dialog element, as they offer more control. To close a dialog, you can simply use the `close()` method.</p><p>Styling the Dialog Element:<br>One of the remarkable aspects of the dialog element is its ease of styling. While the element has some default styles applied to it, you can easily customize its appearance to match your design preferences. Since the dialog element essentially functions as a div, you can apply CSS rules to it just like any other element.</p><pre>dialog {<br>  background: blue;<br>  border: none;<br>  border-radius: 1rem;<br>  z-index: 5;<br>  margin-top: 15px<br>// design the Dialog like any other HTML element<br>}</pre><p>In addition to styling the dialog element itself, you can also style the backdrop that appears behind the dialog without the need for custom HTML or JavaScript. By using the `::backdrop` pseudo-element, you can apply styles to the backdrop, further enhancing the visual appeal.</p><pre>dialog::backdrop {<br>  background-color: hsl(170, 100%, 50%, 0.35);<br>}</pre><p>Advanced Features of the Dialog Element:<br>Beyond its basic usage, the dialog element offers advanced features that can enhance your web development experience.</p><p>1. Forms: If you have a form within a dialog, you can set the `method` attribute of the form to “dialog”. This causes the form to close the dialog upon submission without actually submitting the form data. The data is saved within the form, allowing for the preservation of inputted information even if the dialog is reopened.</p><pre>&lt;dialog&gt;<br>  &lt;form method=&quot;dialog&quot;&gt;<br>    &lt;input type=&quot;text&quot; /&gt;<br>    &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>  &lt;/form&gt;<br>&lt;/dialog&gt;</pre><p>2. Close On Outside Click: While the dialog element does not natively support closing the dialog by clicking outside of it, you can easily add this functionality using event listeners. By listening for click events on the dialog element and checking if the click occurred outside the dialog’s dimensions, you can close the dialog accordingly.</p><pre>dialog.addEventListener(&quot;click&quot;, e =&gt; {<br>  const dialogDimensions = dialog.getBoundingClientRect()<br>  if (<br>    e.clientX &lt; dialogDimensions.left ||<br>    e.clientX &gt; dialogDimensions.right ||<br>    e.clientY &lt; dialogDimensions.top ||<br>    e.clientY &gt; dialogDimensions.bottom<br>  ) {<br>    dialog.close()<br>  }<br>})</pre><p>Conclusion:<br>The HTML dialog element empowers web developers to create highly interactive and engaging dialog boxes. In this comprehensive blog post, we explored the concept of the dialog element, its various use cases, and provided real-world code examples. By incorporating the HTML dialog element into your web applications, you can elevate user interactions and deliver a seamless user experience. Embrace the power of the dialog element and revolutionize your web development journey today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eab50e8e9946" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>