DEV Community

Cover image for The Role of Accessibility in Modern HTML: Making the Web Usable for Everyone
martin rojas
martin rojas

Posted on

The Role of Accessibility in Modern HTML: Making the Web Usable for Everyone

Web accessibility is often an afterthought, but it should be a core principle of web development. A truly inclusive web ensures that everyone—regardless of ability—can navigate, understand, and interact with content.

The good news? HTML itself is evolving to make accessibility more built-in and less reliant on hacks. Features like the <search> element, the inert attribute, and the <dialog> element help developers build accessible websites with minimal extra effort.

In this post, we’ll explore:

✅ Why accessibility (a11y) matters in web development.

✅ How new HTML features improve accessibility by default.

✅ Practical tips for using semantic elements for better usability.

✅ How to test and ensure your website is fully inclusive.

Let’s make the web a better place for everyone! 🚀


Why Accessibility Matters

💡 Did you know? Over 1 billion people worldwide have a disability that affects how they use the web. Accessibility isn’t just about compliance—it’s about ensuring that everyone can access the same content and functionality.

Common Accessibility Barriers

🚫 Keyboard Navigation Issues – Some users rely on keyboard-only navigation but can’t access key features.

🚫 Poor Color Contrast – Low-contrast text makes reading difficult for visually impaired users.

🚫 Missing ARIA Roles – Screen readers struggle when elements lack semantic meaning.

🚫 Unclear Focus States – If focus indicators are removed, keyboard users can’t tell where they are on the page.

Accessibility isn’t just an ethical concern—it’s legally required in many places (e.g., WCAG, ADA compliance). But instead of relying on extra ARIA attributes and JavaScript fixes, modern HTML now includes built-in accessibility improvements.


1. The <search> Element: Better Semantics for Search Forms

The Problem:

Previously, developers wrapped search bars in <div> or <form> elements, but screen readers didn’t automatically understand that it was a search area.

🔴 Bad Example (Generic <div>):

<div id="search-bar">
  <input type="text" placeholder="Search...">
</div>
Enter fullscreen mode Exit fullscreen mode

🟢 Better Example (<search> Element):

<search>
  <input type="text" placeholder="Search...">
</search>
Enter fullscreen mode Exit fullscreen mode

Why This Helps:

<search> automatically applies ARIA role="search", improving screen reader support.

✅ It provides clearer meaning to search forms for assistive technologies.

✅ Older browsers simply treat <search> as a generic block, so it won’t break layouts.

Use It When:

✔ Your website has a global or site-specific search bar.

✔ You want better semantic markup with zero extra effort.


2. The inert Attribute: Removing Unwanted Interactions

The Problem:

When opening modals or overlays, background content remains interactive—leading to confusing navigation for users using screen readers or keyboards.

🔴 Bad Example (Interactive Background):

<div class="overlay">
  <p>This modal is open</p>
</div>
<div>
  <p>Users can still tab through this content 😬</p>
</div>
Enter fullscreen mode Exit fullscreen mode

🟢 Better Example (Using inert to Disable Background):

<div inert>
  <p>This background content is temporarily disabled.</p>
</div>
<dialog open>
  <p>This modal is active</p>
</dialog>
Enter fullscreen mode Exit fullscreen mode

Why This Helps:

inert removes elements from the accessibility tree, preventing screen readers from reading hidden content.

✅ It disables keyboard interactions on background elements.

✅ Works without JavaScript, making modals and overlays more accessible by default.

Use It When:

✔ You need to disable background content while a modal is open.

✔ You want to avoid JavaScript-based workarounds for focus management.


3. The <dialog> Element: A Built-In Accessible Modal

Modals (pop-ups) are notoriously difficult to make accessible because developers must manually manage focus, prevent background interactions, and ensure proper keyboard behavior.

Luckily, the <dialog> element solves these issues natively!

🔴 Bad Example (Custom Modal with JavaScript)

<div class="custom-modal">
  <p>This is a modal</p>
  <button onclick="closeModal()">Close</button>
</div>
Enter fullscreen mode Exit fullscreen mode

🟢 Better Example (<dialog> for Native Modals)

<dialog id="myDialog">
  <p>This is an accessible modal.</p>
  <button onclick="document.getElementById('myDialog').close()">Close</button>
</dialog>

<button onclick="document.getElementById('myDialog').showModal()">Open Modal</button>
Enter fullscreen mode Exit fullscreen mode

Why This Helps:

✅ Automatically traps focus inside the modal, preventing accidental tabbing into background content.

✅ Works with inert, so background elements become unclickable.

Requires less JavaScript than custom modal implementations.

Use It When:

✔ Your site has modals, pop-ups, or confirmation dialogs.

✔ You want an accessible, built-in solution without external dependencies.


4. Keyboard Navigation & Focus Management

Users who rely on keyboard-only navigation often struggle with sites that:

❌ Hide focus indicators (outline: none;).

❌ Have improper tab order.

❌ Lack focus trapping in modals or dropdowns.

🔹 Example: Ensuring Focus is Visible

button:focus, a:focus {
  outline: 2px solid #007BFF; /* Ensures visible focus */
}
Enter fullscreen mode Exit fullscreen mode

🔹 Example: Enforcing Logical Tab Order

<a href="#">Link 1</a>
<a href="#" tabindex="3">Link 3</a>
<a href="#" tabindex="2">Link 2</a>
Enter fullscreen mode Exit fullscreen mode

🔹 Example: Moving Focus into a Modal

document.getElementById('myDialog').addEventListener('open', () => {
  document.getElementById('closeButton').focus();
});
Enter fullscreen mode Exit fullscreen mode

Final Thoughts: Making Accessibility a Priority

HTML is evolving to make accessibility easier for developers—but adopting best practices is still essential.

Key Takeaways:

The <search> element improves search form semantics.

The inert attribute prevents unwanted interactions.

The <dialog> element provides built-in modal accessibility.

Keyboard navigation should always be considered.

Testing accessibility ensures a better experience for all users.

By embracing these features and testing regularly, we can create a more inclusive web for everyone. 🌍💙


Coming Up Next: View Transitions – Bringing Seamless Page Transitions to the Web

In the next post, we’ll explore how CSS View Transitions are revolutionizing page-to-page animations—reducing reliance on JavaScript-heavy frameworks like React and Vue.

You’ll learn how to:

🔹 Use CSS-only transitions for a smoother UX.

🔹 Reduce flashy reload effects when navigating pages.

🔹 Implement progressive enhancements for older browsers.

Stay tuned! 🚀

What accessibility challenges have you faced? Drop a comment below!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay