0
0
HTMLmarkup~5 mins

Why accessibility matters in HTML

Choose your learning style9 modes available
Introduction

Accessibility means making websites easy for everyone to use, including people with disabilities. It helps more people enjoy and understand your content.

When building a website that anyone can visit, including people with vision or hearing difficulties.
When you want your website to work well with screen readers or keyboard navigation.
When you want to follow laws or guidelines that require websites to be accessible.
When you want to improve your website's usability for all users, not just those with disabilities.
When you want to reach a wider audience and show you care about all visitors.
Syntax
HTML
No specific code syntax applies here, but accessibility involves using semantic HTML elements and ARIA attributes properly.
Use semantic HTML tags like
,
Add ARIA labels and roles to describe elements when needed for assistive technologies.
Examples
This button has an ARIA label to describe its purpose to screen readers.
HTML
<button aria-label="Close menu">x</button>
Using the <nav> element helps users and assistive devices know this is the main navigation.
HTML
<nav>
  <ul>
    <li><a href="#home">Home</a></li>
    <li><a href="#about">About</a></li>
  </ul>
</nav>
Sample Program

This simple webpage uses semantic HTML and an ARIA label on the navigation to help screen readers understand the page structure.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Accessible Example</title>
</head>
<body>
  <header>
    <h1>Welcome to Our Website</h1>
  </header>
  <nav aria-label="Main navigation">
    <ul>
      <li><a href="#home">Home</a></li>
      <li><a href="#services">Services</a></li>
      <li><a href="#contact">Contact</a></li>
    </ul>
  </nav>
  <main>
    <section>
      <h2>About Us</h2>
      <p>We make websites that everyone can use.</p>
    </section>
  </main>
  <footer>
    <p>Contact us at <a href="mailto:info@example.com">info@example.com</a></p>
  </footer>
</body>
</html>
OutputSuccess
Important Notes

Accessibility improves the experience for all users, not just those with disabilities.

Testing with keyboard only and screen readers helps find accessibility issues.

Good color contrast and readable fonts also help accessibility.

Summary

Accessibility means making websites usable by everyone.

Use semantic HTML and ARIA labels to help assistive technologies.

Accessible websites reach more people and follow good practices.