HTML Accessibility


HTML Accessibility means designing and coding web pages so that all users, including those with disabilities (like visual, auditory, motor, or cognitive impairments), can easily access, understand, and interact with content.

Accessibility follows WCAG (Web Content Accessibility Guidelines) and promotes the idea of an inclusive web.


🔹 Why Accessibility Matters

  • Legal compliance (e.g., ADA, Section 508)

  • Better user experience for everyone

  • Improves SEO and usability

  • Makes web content available to screen readers, keyboard-only users, and others with assistive technologies


🔹 Key Accessibility Features in HTML

1. Semantic HTML

Use meaningful elements like <header>, <nav>, <main>, <section>, <footer>, etc.

<header>
  <h1>Welcome to My Site</h1>
</header>

2. Alt Text for Images
<img src="logo.png" alt="Company Logo" />

Avoid empty alt="" unless the image is decorative.


3. Form Labeling
<label for="email">Email Address:</label>
<input type="email" id="email" name="email" />

4. Keyboard Navigation

Use tabindex, avoid onclick without a fallback, and ensure all interactive elements are reachable via keyboard.


5. ARIA (Accessible Rich Internet Applications) Attributes

Use role, aria-label, aria-hidden, etc., where needed:

<div role="alert">Form submission failed</div>

6. Using Headings Properly

Structure content with headings (<h1> to <h6>) in a logical order.


7. Accessible Tables

Include caption, thead, tbody, and scope:

<table>
  <caption>Employee Data</caption>
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th></tr>
  </thead>
  <tbody>
    <tr><td>Alice</td><td>Developer</td></tr>
  </tbody>
</table>

Practice Questions

Q1. Create a form with properly labeled input fields.

Q2. Add an image with descriptive alt text.

Q3. Convert a non-semantic layout into semantic HTML5 structure.

Q4. Use ARIA attributes to make a custom button accessible.

Q5. Create a table with captions and scope attributes.

Q6. Demonstrate keyboard navigation using tabindex.

Q7. Write an alert message using role="alert".

Q8. Build a navigation bar that is accessible for screen readers.

Q9. Write an accessible modal dialog example.

Q10. Fix accessibility issues in a sample form (missing labels, improper inputs).


Go Back Top