<?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 Filip Peralov on Medium]]></title>
        <description><![CDATA[Stories by Filip Peralov on Medium]]></description>
        <link>https://medium.com/@fperalov?source=rss-8192fc0a20d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8OZRFlqrBZktJyAP9DzD6g.png</url>
            <title>Stories by Filip Peralov on Medium</title>
            <link>https://medium.com/@fperalov?source=rss-8192fc0a20d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:26:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fperalov/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[Accessible Web Apps: A Div Is Not a Button]]></title>
            <link>https://medium.com/@fperalov/accessible-web-apps-div-is-not-a-button-011b7ee67215?source=rss-8192fc0a20d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/011b7ee67215</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[wcag]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Filip Peralov]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 10:51:58 GMT</pubDate>
            <atom:updated>2026-06-02T10:51:58.409Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern frontend frameworks give us structure to build complex, scalable web platforms. But if you look under the hood of many enterprise applications, you will find hundreds of clickable &lt;div&gt; elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H-4T9nSmR0ZxaIiOnAwvuA.png" /><figcaption>Web App Accessibility: A Div Is Not a Button</figcaption></figure><p>Relying on the most generic layout container for core user interactions is more than lazy — it breaks the web for users who rely on assistive technologies, worsens native browser performance, and introduces technical debt.</p><p>The examples used in this article are using <em>Angular</em>, but the same principle applies in <em>any other frontend framework</em> or plain html.</p><h3>Ban Clickable Divs</h3><p>I have been guilty of abusing click events on &lt;div&gt; elements just like anybody else, but after fixing hundreds of <a href="https://www.w3.org/WAI/standards-guidelines/wcag/"><em>WCAG</em></a> issues as a result of this pattern, I have learned my lesson.</p><pre>❌ Looks like a button but breaks accessibility<br>&lt;div <br>  class=&quot;btn-primary&quot;<br>  (click)=&quot;saveChanges()&quot;&gt;<br>  Save Changes<br>&lt;/div&gt;</pre><p>Attaching click events to non-interactive tags like &lt;div&gt;, &lt;span&gt;, &lt;p&gt; , &lt;h1&gt;, breaks core browser accessibility and forces you to reinvent the wheel with messy fixes.</p><h3>Don’t reinvent the button</h3><p>If you were forced to make a generic &lt;div&gt; match the accessibility and functionality of a native &lt;button&gt;, you cannot just use a simple (click) binding. You would have to manually implement all the native browser logic yourself:</p><pre>&lt;!-- ❌ The over-engineered, high-maintenance &quot;accessible&quot; div --&gt;<br>&lt;div <br>  class=&quot;btn-primary&quot; <br>  tabindex=&quot;0&quot; <br>  role=&quot;button&quot;<br>  (click)=&quot;saveChanges()&quot;<br>  (keydown.enter)=&quot;$event.preventDefault(); saveChanges()&quot;<br>  (keydown.space)=&quot;$event.preventDefault(); saveChanges()&quot;<br>  [class.disabled]=&quot;isSaving&quot;<br>  [attr.aria-disabled]=&quot;isSaving&quot;&gt;<br>  Save Changes<br>&lt;/div&gt;</pre><p>On top of writing extra html just to handle keyboard tracking and basic screen reader roles, you have to write additional code in your component controller and custom css styles because a generic &lt;div&gt; doesn&#39;t natively understand how to be interactive, focused, or disabled.</p><h3>Use a button</h3><p>For actions that change data or trigger a state, use a &lt;button&gt;. As one of the base HTML elements the button serves a much greater purpose than just being a styled box on the screen.</p><p>It brings a lot of pre-built behaviours. It maps click events to appropriate keyboard shortcuts, handles automatic form submission, prevents accidental text highlighting and can be easily disabled.</p><pre>&lt;!-- ✅ 100% accessible, focusable, and semantic out of the box --&gt;<br>&lt;button <br>  type=&quot;button&quot; <br>  class=&quot;btn-primary&quot; <br>  (click)=&quot;saveChanges()&quot; <br>  [disabled]=&quot;isSaving&quot;&gt;<br>  Save Changes<br>&lt;/button&gt;</pre><p>By simply choosing a native &lt;button&gt; element paired with Angular&#39;s native property binding [disabled]=&quot;isSaving&quot;, the browser takes care of all this automatically.</p><h3>Avoid: The clickable table row 🫩</h3><p>Another place where this anti-pattern frequently appears into dashboards is data grids. Developers may attach a (click) binding to an entire table row (&lt;tr&gt;) to toggle an expanded view, open a sidebar, or navigate to a detail page.</p><pre>&lt;!-- ❌ Is it a row or a button? --&gt;<br>&lt;tr (click)=&quot;toggleRow(row.id)&quot;&gt;<br>  &lt;td&gt;{{ row.name }}&lt;/td&gt;<br>  &lt;td&gt;{{ row.status }}&lt;/td&gt;<br>  &lt;td&gt;&lt;button (click)=&quot;deleteRow(row.id)&quot;&gt;Delete&lt;/button&gt;&lt;/td&gt;<br>&lt;/tr&gt;</pre><p>A table row has an inherent structural role of “row”. The element roles get conflicted. Is this a row in a data grid, or is it a button?</p><p>To make this row function remotely close to an accessible control for keyboard or screen reader users, you can’t just use a simple template binding. You are forced to manually inject lots of boilerplate directly onto the structural table tag:</p><pre>&lt;!-- ❌ The over-engineered, high-maintenance &quot;accessible&quot; table row --&gt;<br>&lt;tr <br>  class=&quot;custom-row-button&quot; <br>  tabindex=&quot;0&quot; <br>  role=&quot;button&quot;<br>  [attr.aria-expanded]=&quot;row.expanded&quot;<br>  [attr.aria-label]=&quot;(row.expanded ? &#39;Collapse&#39; : &#39;Expand&#39;) + row.name&quot;<br>  (click)=&quot;toggleRow(row.id)&quot;<br>  (keydown.enter)=&quot;$event.preventDefault(); toggleRow(row.id)&quot;<br>  (keydown.space)=&quot;$event.preventDefault(); toggleRow(row.id)&quot;&gt;<br>  &lt;td&gt;{{ row.expanded ? &#39;-&#39; : &#39;+&#39; }}&lt;/td&gt;<br>  &lt;td&gt;{{ row.name }}&lt;/td&gt;<br>  &lt;td&gt;{{ row.status }}&lt;/td&gt;<br>  &lt;td&gt;<br>    &lt;!-- Event interception to stop row triggers --&gt;<br>    &lt;button <br>      type=&quot;button&quot; <br>      class=&quot;btn-danger&quot;<br>      (click)=&quot;$event.stopPropagation(); deleteRow(row.id)&quot;&gt;<br>      Delete<br>    &lt;/button&gt;<br>  &lt;/td&gt;<br>&lt;/tr&gt;</pre><p>When a screen reader user navigates to this row, the browser attempts to read every single data cell inside the row back-to-back as one single, continuous, chaotic button description.</p><h3>Event Bubbling Issues</h3><p>Placing a real &lt;button&gt; inside an already clickable &lt;tr&gt; creates a severe JavaScript event propagation bug. Because of standard DOM event bubbling, clicking that inner &quot;Delete&quot; button will trigger your deleteRow() logic, and then bubble up and trigger toggleRow() on the parent row. To stop this, you are forced to do $event.stopPropagation() somewhere in the code.</p><h3>Sometimes the UX is the problem</h3><p>Instead of writing heavy JavaScript or complex TypeScript decorators to patch a flawed UI layout, bring the problem to your design and product teams.</p><p>Show them how making a giant container or a table row clickable introduces severe user experience barriers for screen readers and mobile touch devices. Propose a design change: add an explicit, native &lt;button&gt; or a clear text link <em>inside</em> the layout to cleanly isolate the action.</p><p>Keep your data grid structure pure and preserve standard <em>HTML</em> table layout trees. Place an explicit, accessible &lt;button&gt; inside the very first cell to handle the expansion behaviour.</p><pre>&lt;!-- ✅ Pure table semantics with native controls --&gt;<br>&lt;tr&gt;<br>  &lt;td&gt;<br>    &lt;button <br>      type=&quot;button&quot; <br>      class=&quot;btn-toggle&quot;<br>      (click)=&quot;toggleRow(row.id)&quot; <br>      [attr.aria-expanded]=&quot;row.expanded&quot;<br>      [attr.aria-label]=&quot;(row.expanded ? &#39;Collapse&#39; : &#39;Expand&#39;) + row.name&quot;<br>      {{ row.expanded ? &#39;-&#39; : &#39;+&#39; }}<br>    &lt;/button&gt;<br>  &lt;/td&gt;<br>  &lt;td&gt;{{ row.name }}&lt;/td&gt;<br>  &lt;td&gt;{{ row.status }}&lt;/td&gt;<br>  &lt;td&gt;<br>    &lt;button <br>      type=&quot;button&quot; <br>      class=&quot;btn-danger&quot; <br>      (click)=&quot;deleteRow(row.id)&quot;&gt;<br>      Delete<br>    &lt;/button&gt;<br>  &lt;/td&gt;<br>&lt;/tr&gt;</pre><h3>Can we add an additional click on the container ?</h3><p>Can we maybe attach an (click) event to a &lt;tr&gt; or &lt;div&gt; <em>only</em> as a visual shortcut for mouse and mobile users, as long there is a dedicated button for the same action? In theory if we don’t add role=&quot;button&quot; or tabindex=&quot;0&quot;, the accessibility tree ignores the container, while mouse users get a larger, touch-friendly click target.</p><pre>&lt;!-- ❌ Hidden visual trap --&gt;<br>&lt;div <br>  class=&quot;custom-card&quot; <br>  (click)=&quot;viewProduct(product.id)&quot;&gt;<br>    &lt;img <br>      [src]=&quot;product.imageUrl&quot;<br>      [alt]=&quot;product.imageDescription&quot;&gt;<br>    &lt;h3&gt;{{ product.name }}&lt;/h3&gt;<br>    &lt;p&gt;{{ product.description }}&lt;/p&gt;<br>    &lt;button<br>      type=&quot;button&quot; <br>      class=&quot;btn-fav&quot;<br>      [attr.aria-label]=&quot;&#39;View &#39; + product.name&quot;<br>      (click)=&quot;$event.stopPropagation(); viewProduct(product.id)&quot;&gt;View&lt;/button&gt;<br>&lt;/div&gt;</pre><p>But this pattern introduces a hidden trap for low-vision users.</p><p>Consider a user who has partial vision and uses the mouse to explore the app but relies on a screen reader for the content bellow the cursor. When they hover over your clickable custom-card &lt;div&gt;, the mouse tells them the area is interactive, but the screen reader treats it as regular div. If they click it, the layout suddenly changes without warning.</p><h3>Final Thoughts</h3><p>Like many frontend developers, I viewed semantic HTML in web apps as an afterthought and accessibility as a post-development checklist. It took a client demanding accessibility compliance to finally force it onto my radar.</p><p>But after spending a year fixing an inaccessible web application, I realised something critical: building accessible software is a fundamental developer responsibility, not an optional feature</p><p>Engineering accessible apps starts by respecting the very building blocks of the browser. Choosing a native &lt;button&gt; over a lazy &lt;div&gt; wrapper isn&#39;t a minor stylistic preference - it is a foundational architectural choice. It means letting the browser handle user interaction, keyboard navigation, and assistive technologies out of the box instead of reinventing the wheel.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=011b7ee67215" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>