Skip to content

Web Developers Accessibility Do's and Don'ts

Yaritza M. Garcia Chaparro edited this page Oct 15, 2024 · 1 revision

DO’s:

  1. Do Use Semantic HTML

    • Use proper HTML5 elements (<header>, <nav>, <main>, <footer>, <article>, <button>, etc.) to give meaning and structure to your content.
    • This helps screen readers and assistive technologies interpret the page correctly.
  2. Do Ensure Keyboard Accessibility

    • Make sure all interactive elements (buttons, forms, links, menus) are fully navigable and operable with the keyboard.
    • Test using Tab, Shift+Tab, Enter, Space, and arrow keys to ensure smooth navigation.
  3. Do Provide Alternative Text for Images

    • Use descriptive alt="brief description" attributes for all relevant images. If an image is decorative, set alt="" (empty) to prevent screen readers from reading it.
    • Ensure the alt text conveys the purpose or meaning of the image, not just a literal description.
  4. Do Maintain Sufficient Color Contrast

    • Ensure text and background colors meet the minimum contrast ratio (4.5:1 for normal text, 3:1 for large text).
    • Use tools like the Contrast Checker or WCAG contrast guidelines to verify your design.
  5. Do Label Form Inputs and Controls Properly

    • Use <label> elements to associate labels with form fields for screen readers.
    • Add aria-label or aria-labelledby where necessary, and ensure all controls are accessible and understandable.
  6. Do Provide Visible Focus Indicators

    • Ensure that focus states are obvious when navigating with the keyboard. Customize focus styles using CSS (:focus) to maintain or enhance visibility.
  7. Do Use ARIA Responsibly

    • Use ARIA (Accessible Rich Internet Applications) attributes when native HTML elements are insufficient, but always prefer semantic HTML over ARIA where possible.
    • Ensure dynamic content is announced correctly using ARIA roles and attributes like aria-live, aria-expanded, and aria-hidden.
  8. Do Test with Screen Readers

    • Regularly test your website using screen readers like NVDA, JAWS (for Windows), or VoiceOver (for macOS).
    • Ensure content and interactions are fully accessible and logical when read aloud.
  9. Do Add Captions and Transcripts for Multimedia

    • Provide captions for videos and transcripts for audio content to accommodate users with hearing impairments.
    • Ensure that these are synchronized with the media and accessible via both screen readers and sighted users.
  10. Do Validate Your Accessibility

    • Use automated tools like Lighthouse, axe, or WAVE to scan for common accessibility issues.
    • Combine automated testing with manual testing to catch issues that tools may miss.

DON’Ts:

  1. Don’t Rely Solely on Color to Convey Information

    • Avoid using color as the only way to differentiate or convey meaning (e.g., using only red text to indicate an error).
    • Use text, icons, or patterns in addition to color.
  2. Don’t Disable Zoom

    • Don’t prevent users from zooming on your website (e.g., by using maximum-scale=1 in the viewport meta tag).
    • Ensure that the layout adapts well to zoom levels up to 400%.
  3. Don’t Use Low Contrast Text

    • Avoid light text on light backgrounds or dark text on dark backgrounds.
    • This makes reading difficult, especially for users with visual impairments or low vision.
  4. Don’t Forget About Focus Traps

    • Don’t create interfaces where users can become stuck (e.g., modals or pop ups that don’t allow users to tab out).
    • Always make sure users can easily exit modal windows and dialogs using the keyboard.
  5. Don’t Rely on Hover Effects Alone

    • Don’t use hover effects (like tooltips or dropdowns) as the only way to display essential content.
    • Ensure that these interactions work for keyboard users and screen readers by using focus or click events.
  6. Don’t Auto-play Video or Audio Without Controls

    • Avoid videos or audio that play automatically without giving users control to pause or stop them.
    • Auto-playing media can confuse or overwhelm users, especially those using screen readers.
  7. Don’t Use Non-Descriptive Links or Buttons

    • Avoid generic link texts like “Click here” or “Read more.” Instead, make sure your link text describes the destination (e.g., “Read more about our accessibility policy”).
    • Screen reader users often navigate by links, so descriptive text is essential.
  8. Don’t Overuse ARIA Attributes

    • Avoid using ARIA unless absolutely necessary. Misusing or overusing ARIA roles and properties can confuse assistive technologies.
    • Stick to native HTML elements whenever possible, as they come with built-in accessibility.
  9. Don’t Forget About Mobile Accessibility

    • Don’t assume that accessible desktop sites automatically work well on mobile.
    • Test for touch accessibility (e.g., large touch targets, easy navigation) and ensure your content is readable and operable on mobile devices.
  10. Don’t Overcomplicate Navigation

    • Avoid complex or inaccessible navigation patterns like mega menus or multi-level dropdowns that are hard to use with a keyboard or screen reader.
    • Ensure your navigation is straightforward, logical, and accessible.

Conclusion

By following these Do’s and Don’ts, developers can ensure that they’re building accessible, user-friendly websites for everyone, regardless of ability. Always aim to test and improve accessibility throughout the development lifecycle.