Make your website accessible in just 1 click – trusted by over 60,000 websites worldwide

Why Using
as a Button is Bad Practice

Woman using assistive technology keyboard for web accessibility, with man pointing at a laptop screen, highlighting need for accessible web applications and platforms.
Man smiling, wearing an allyWay t-shirt, promoting web accessibility solutions.
Posted by

Wagner Matthias

Uploaded at

February 29, 2024

Subscribe to the Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus

You can unsubscribe at any time. We process your data in accordance with our Privacy Policy.

Why Using <div> as a Button is Bad Practice

Introduction

Digital accessibility is not a luxury—it's a necessity. As businesses, government entities, and organizations move increasingly online, ensuring that digital platforms are inclusive for all users becomes a top priority. But even in 2024, common HTML mistakes persist that significantly hinder accessibility and usability for millions of people worldwide. One such practice is the misuse of the <div> element as a clickable button.

At first glance, using a <div> as a button might seem like a harmless shortcut. Developers often style <div> elements to look and function like buttons using JavaScript and CSS. But underneath the surface, this approach introduces serious accessibility issues and creates considerable obstacles for users relying on assistive technologies like screen readers or keyboard navigation.

In this article, we'll explore in-depth why using <div> as a button is considered bad practice, the repercussions it has on user experience and compliance with standards like WCAG, and how tools like allyWay.io can support your accessibility efforts. Whether you're a web developer, digital agency, or business owner, understanding these foundational practices is vital in creating digital spaces that are inclusive, efficient, and user-friendly.


Why Developers Use <div> as a Button

Before we dive into the technical and legal issues, it’s worth understanding the rationale behind this choice. Developers may opt to use a <div> as a button because:

  • It offers more flexibility in styling
  • It simplifies positioning within certain layouts
  • It avoids browser-specific button styling defaults
  • They misunderstand its impact on accessibility

While these reasons might offer short-term convenience, they come with long-term costs. Maintaining inaccessible code can affect usability, increase legal risk, and create frustrated users who may never return to your site.


The Role of Semantic HTML in Accessibility

Semantic HTML is the practice of using HTML elements according to their intended purpose. For example, using <button> for interactive button actions instead of <div> or <span>. This isn’t just about cleaner code—it’s a cornerstone of accessibility.

Why Semantic Elements Matter

Semantic HTML elements communicate meaningful information to assistive technologies. They help:

  • Screen readers understand the purpose of elements
  • Browsers provide built-in keyboard behavior
  • Search engines better interpret page structure
  • Developers future-proof their websites

For example, the <button> element is inherently:

  • Focus-aware: It can be accessed via the Tab key
  • Keyboard-operable: It can be triggered using the Enter or Space key
  • Announced properly: Screen readers identify it as a button

When you replace a <button> with a <div> (styled to look like one), all this built-in functionality disappears—unless you add extensive custom scripting and ARIA roles, and even then, the result may still fall short.


Accessibility Impacts: The Hidden Cost of Non-Semantic Elements

What Happens When You Use <div> as a Button?

  1. Screen readers don’t recognize it as a button

    • Without ARIA attributes, screen readers will simply announce it as a generic container.
  2. Keyboard users can’t reach it or activate it

    • By default, <div> elements aren't focusable or operable using a keyboard.
  3. You must manually add role, tabindex, and key handlers

    • Developers need to add role="button" and tabindex="0" and handle keydown events—adding complexity and room for error.
  4. ARIA may not be enough

    • ARIA (“Accessible Rich Internet Applications”) can help mimic native behavior, but it doesn’t fix all issues. As the saying in accessibility goes: “Use native HTML when you can, ARIA when you must.”

How This Violates WCAG and Other Accessibility Guidelines

Using a <div> as a button without proper accessibility roles and scripting can lead to non-conformance with key accessibility standards, including:

  • WCAG (Web Content Accessibility Guidelines):

    • Success Criterion 4.1.2 – Name, Role, Value
    • Success Criterion 2.1.1 – Keyboard Accessibility
  • EN 301 549 (the European accessibility standard)

  • Section 508 (US federal agencies' standard)

  • ADA (when publicly available websites need to be accessible)

Though no tool can guarantee compliance with these laws (and nor should they claim to), adopting best practices in web development is essential to reduce potential legal exposure and create better user experiences.


The Better Alternative: Use the <button> Element

The native <button> element exists for a reason—it’s built to be accessible and functional out-of-the-box.

Advantages of Using <button> Correctly

Feature <button> <div> (styled as button)
Accessible by default ✓ ✗
Keyboard-operable ✓ ✗ (requires scripting)
Screen reader support ✓ ✗ (requires ARIA)
Requires minimal effort to implement ✓ ✗
Built-in semantics ✓ ✗

Best Practice Tip: If you need advanced styling, apply CSS to a <button> directly. There's no need to sacrifice accessibility for aesthetics.


Real-World Implications for Business Owners

Using <div> as a button increases the chances of:

  • Accessibility audits failing
  • User drop-offs due to inaccessible navigation
  • Negative brand perception among disabled users
  • Increased time and cost for fixing issues later

In today’s legal climate, digital accessibility lawsuits are rising globally. While tools like allyWay don't guarantee conformance, they can assist businesses by identifying accessibility issues early and offering scalable, smart solutions that support ongoing accessibility improvements.


allyWay: Your Partner in Building a More Accessible Web

allyWay is an AI-powered accessibility solution designed for websites and web applications. More than just a plugin or overlay, allyWay supports accessibility strategies through:

  • ✓ Over 30 accessibility optimization features
  • ✓ 5 customizable accessibility profiles for different user needs
  • ✓ Automatic detection of potential barriers
  • ✓ AI-powered audits to track progress
  • ✓ Support for 35+ languages

By integrating allyWay into your accessibility workflow, you can reduce barriers, streamline accessibility efforts, and improve your site’s usability for a broader range of users.


How to Refactor Inaccessible Code

Here’s a simple example of how you might refactor a div acting as a button into a properly accessible button.

Before:

<div onclick="submitForm()" class="submit-btn">Submit</div>

Accessibility Issues:

  • Not keyboard operable
  • Not identified as a button
  • Not focusable

After:

<button onclick="submitForm()" class="submit-btn">Submit</button>

Benefits:

  • Focusable and operable by keyboard
  • Screen reader-friendly
  • Minimal code changes with maximum accessibility return

You can still add styling to make the button look exactly as needed:

.submit-btn {
  background-color: #007bff;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
}

Common Misconceptions Debunked

“But ARIA makes everything accessible!”

ARIA helps only when native HTML elements can’t serve the purpose. Overusing ARIA or misusing it can actually harm accessibility.

“Buttons don’t match our design system.”

Then adjust your design system—it shouldn’t come at the cost of exclusion. With CSS, you can fully customize a <button>’s appearance.

“It’s just one div, no big deal.”

Inaccessibility scales quickly. One bad pattern often spreads across components, pages, or entire sites.


How allyWay Supports Best Practices

allyWay doesn’t just offer generic accessibility overlays. It’s built to support serious efforts toward improving digital accessibility, helping developers and businesses catch patterns like div misuse early in the development process.

Key Accessibility Support Features

Feature allyWay Accessibility Solution
AI-powered accessibility audit ✓
Code pattern analysis ✓
Inaccessible element alerts ✓
Accessibility profile customization ✓
Support for regulatory frameworks ✓
Continuous updates with WCAG guidance ✓

Whether you’re managing one website or hundreds, allyWay offers a scalable and time-saving platform to embed accessibility into your practice from the ground up.


FAQ: Using <div> as a Button

Why is using a <div> as a button bad for accessibility?

Because it removes built-in keyboard navigation, focus handling, and semantic meaning—all of which are essential for users relying on assistive tech.

Can’t ARIA fix the problem?

ARIA can help, but it doesn’t replace native HTML features. Relying on ARIA introduces added complexity and potential failure points.

What’s the risk of not fixing this?

It can lead to poor user experience, lower SEO, failed audits, and an increased risk of receiving an accessibility complaint or lawsuit.

How can I tell if my site uses <div>s improperly?

Use an accessibility auditing tool like allyWay to detect patterns across your codebase and receive actionable guidance.

This blog is for informational purposes only and does not constitute legal advice. We make no representations or warranties regarding the accuracy, completeness, or applicability of the content. Accessibility requirements may vary by jurisdiction and use case. To the extent permitted by law, we disclaim any liability arising from reliance on the information provided. 

Related Articles
Diverse team discusses web accessibility at a laptop, highlighting inclusion and accessible web applications; a woman with a white cane walks in the background.

Why Proper Form Field Validation Improves Inclusion

Title: Why Proper Form Field Validation Improves Inclusion Introduction In today’s digital-first world, creating…
Team working together on web accessibility solutions using laptops and accessibility software in a modern office workspace.

Why Webflow is a Great Choice for Accessible Design

Why Webflow is a Great Choice for Accessible Design Introduction In today’s digital-first world,…
Three people using web accessibility software, with subtitles on screens and assistive tools, promoting inclusive SaaS platforms and web applications.

Accessible Video Content: Captions vs. Subtitles vs. Transcripts

Accessible Video Content: Captions vs. Subtitles vs. Transcripts In today’s digital-first world, video has…
Three people using web accessibility software and a braille device at a desk, collaborating on website accessibility for SaaS platforms and web applications.

10 Must-Have Features of a Modern Accessibility Widget

Title: 10 Must-Have Features of a Modern Accessibility Widget Introduction In today's digital-first world,…
Diverse team discusses web accessibility, allyWay, and SaaS platforms. Smiling woman uses tablet in wheelchair, promoting inclusive web applications and accessibility software for websites.

White-Labeling Allyway: Your Own A11Y Tool in Minutes

White-Labeling allyWay: Your Own A11Y Tool in Minutes Introduction In today’s digital-first world, accessibility…
A man using a braille keyboard and computer, demonstrating web accessibility software for websites and web applications in an office setting.

A Guide to Refreshable Braille Displays for Developers

Title: A Guide to Refreshable Braille Displays for Developers Introduction In today’s digital-first world,…
Three people discussing web accessibility software at a computer, including a woman using a screen reader and braille device, with code visible on the monitor.

Evaluating SVG Accessibility with Browser Tools

Evaluating SVG Accessibility with Browser Tools In today’s digital-first world, accessible content isn't a…
Diverse team discusses web accessibility and allyWay solutions in a modern office, including a woman in a wheelchair and accessible technology for SaaS platforms and web applications.

Why “Set and Forget” A11Y is the Ultimate Agency Product

Why "Set and Forget" A11Y is the Ultimate Agency Product Introduction Digital accessibility is…
Blue accessibility loading icon representing Accessibility Software, Accessibility Toolbar, Accessibility for Website, Software for Web Accessibility, Web Accessibility, and Accessibility Audit.

Make your site accessible today

Used by websites worldwide — built in Europe. allyWay delivers instant web accessibility. Set up in under 1 minute — no development required.

1
Choose your Package
2
Install in 1 Minute
3
Add to Your Website
Finished