Fixing the Most Common Accessibility Issues in Web Development: A Complete Guide

The main premise of the internet is its connection and availability to all people, but not every website is created and optimized to be used by everyone. Some of them miss a crucial development category – web accessibility – making it difficult or even impossible for users with disabilities to use them.
For example, imagine you get to a building, but the door has no handle. The signs are written in a color so faint you can’t even see the letters. And the elevator only works if you do a backflip before pressing the button to call it. Sounds ridiculous, right?
Well, that’s exactly how some websites feel to people with disabilities. Web accessibility is about making sure everyone can use the internet without frustration, whether they rely on screen readers, keyboard navigation, or just need text that doesn’t blend into the background like a chameleon.
Making your website accessible doesn’t just help a small group of people; it makes things better for everyone. In this post, we’ll break down why accessibility matters, some common mistakes (spoiler: you might be making a few!), and easy ways to fix them. Let’s make the web a friendlier place with some practical tips.
### **What are Some of the Leading Accessibility Obstacles?**
Understanding the challenges faced by individuals with different disabilities is essential for creating websites that are truly accessible to everyone. So, let's explore the various types of disabilities and the common problems people encounter while navigating digital spaces. By recognizing these issues, you can design better, more accessible experiences for all users.
#### **1. The most common disabilities**
* **Visual impairments** cover a big spectrum, including blindness, low vision, and color blindness. Users within this group may find it difficult to navigate websites that heavily rely on visual cues like images, small text, or low contrast.
* **Hearing impairments** include partial or total hearing loss. Individuals with these conditions may struggle with audio content such as videos, podcasts, or sound alerts. Without captions, transcripts, or other text alternatives, they could miss critical content and become excluded from fully engaging with multimedia content.
* **Mobility impairments** can result from conditions like paralysis, arthritis, or limited dexterity, and they affect a person’s ability to use traditional input methods like a mouse or keyboard. This makes it challenging to interact with websites that require complex or mouse-specific interactions.
* **Cognitive impairments** can be caused by learning disabilities such as dyslexia, ADHD, intellectual disabilities, or people of older ages. They can make it difficult for individuals to understand, remember, or process complex information, and navigating a website with a complicated structure or unclear instructions becomes a frustrating task.
#### **2. The usual problems they face**
* **Inaccessible multimedia content:** Any video or audio clip without captions or transcripts leaves deaf or people with hearing issues at a disadvantage. They often miss important information if there’s no textual alternative.
* **Unclear or complex navigation:** Poor navigation leads to confusion, frustration, and, ultimately, leaving the site – which is probably the worst case since they might not want to revisit the same website. Whether it’s general users or users with cognitive impairments, dealing with a complicated or cluttered navigation system can be an issue.
* **Small or low-contrast text:** Another reason that could lead the user to leave the website is poor readability and low contrast. This is especially problematic for people with color blindness or older adults who experience age-related vision changes.
* **Lack of keyboard accessibility:** Websites that only function with mouse-based interactions or only with a keyboard, but fail to provide keyboard/mouse accessibility for other cases can be a barrier for those with mobility impairments.
* **Non-descriptive images:** Images without proper alt text or descriptions are inaccessible to users relying on screen readers. This makes images, charts, buttons, or any visual content meaningless for those who are blind or have low vision.
### **Fixing Accessibility Barriers**
When it comes to web accessibility, the bread and butter are the WCAG guidelines. If you’re not familiar, it’s a set of recommendations provided for making websites more accessible to everyone, especially people with disabilities. They’re built on **four core principles** that help ensure websites are usable by a wide range of users with different needs:
* **Perceivable** - Content must be available to different senses (sight, hearing, etc.)
* **Operable** - Users must be able to navigate the site using different input methods
* **Understandable** - Information and interactions should be easy to understand
* **Robust** - The site should work well with current and future technologies
Now, a lot can be said about this subject from the design perspective, but in this blog post, we will focus on the development side of it. If you want to know more about the design side, check out this Inclusive UX/UI design blog.
Alright, let’s see how we can put everything into action. We’ll focus on specific solutions that ensure the website is easy to navigate, fully accessible, and compatible with a range of devices and assistive technologies. Let’s break it down into steps to make accessibility a natural part of your development process.
As a developer, you might forget to add the `alt` attribute to images or provide some unhelpful descriptions like "image.jpg". Some developers even overload the `alt` text with irrelevant keywords, thinking it will improve SEO. Unfortunately, this can make screen readers frustrating to use because the content doesn’t provide meaningful information.
**Best practices for alt text:**
* **Be descriptive:** Use clear, concise, and descriptive alt text that explains the image’s purpose in context. For example, instead of just “image.jpg”, use something like "A developer talking to a duck". This way, users who can't see the image will still understand the meaning.
* **Decorative images:** If the image is purely decorative and doesn’t add content or meaning (such as borders, background images, or spacer images), use `alt=""` to indicate that the image should be ignored by screen readers.
* **Automate checking:** Set up linters or use accessibility plugins (like Webhint) that can scan your code to identify any missing or incorrect alt text automatically. This can save you time and ensure that all images are accessible and properly described.
#### **2\. Keyboard Navigation: Making Every Interactive Element Accessible**
A common mistake is creating interactive elements such as modals, dropdowns, carousels, or custom buttons that aren’t natively keyboard navigable. Users who rely on keyboards or other assistive devices will have a hard time interacting with these elements, which can cause confusion or unintended behavior.
**How you can fix it:**
* **Focusable elements:** Ensure that all interactive elements like buttons, links (``<a>``), and form fields (``<input>``, ``<textarea>``) are focusable via the Tab key. This allows users to cycle through them using just the keyboard. If an element is interactive, it should be part of the natural tab order.
* **Visual focus:** Use the `:focus-visible` CSS pseudo-class to ensure that focus states (like a border around buttons or links) are visible when users are navigating via keyboard. This doesn't interfere with mouse users, but it gives keyboard users a visual cue of where they are.
* **Avoid tabindex misuse:** Be careful with the `tabindex` attribute by forcing focus in a non-sequential order. Stick to the natural order of elements on the page for consistency. For example, avoid manually setting `tabindex="1"` on an element if it's out of order.
* **Test navigation:** Play around your website forms using just the keyboard (Tab, Shift+Tab, Enter, Space) to ensure users can move through all interactive elements without getting stuck or lost.
```
<label> First in tab order: <input type="text" /> </label>
<div tabindex="0"> Tabbable due to tabindex. </div>
<div> Not tabbable: no tabindex. </div>
<label> Third in tab order: <input type="text" /> </label>
```
This code shows how to make an element accessible by focusing on it with the tab key using the tabindex attribute.
Forms can be frustrating for users with disabilities if they’re not designed with accessibility in mind. Some of the common issues are missing `<label>` elements or using placeholders in place of labels, which doesn’t provide enough context for screen readers. Also, if forms don’t display clear error messages or provide a way how to correct mistakes, users might get confused or give up on submitting the form.
**How you can make forms more accessible:**
- **Use `<label>` elements:** Always associate each form field with a corresponding `<label>` element. The for attribute of the `<label>` should match the id of the `<input>`. This ensures that screen readers can correctly identify and describe the field. For example:
```
<label for="email">Email</label>
<input type="email" id="email" name="email" />
```
- **Provide error messages:** When there’s an error in the form (like an invalid email format), use clear, specific error messages that explain what needs to be fixed. Make sure these messages are accessible to screen readers, and consider using `aria-live` regions to announce errors dynamically.
#### **4\. ARIA Misuse: When "Fixing" Accessibility Makes It Worse**
ARIA (Accessible Rich Internet Applications) attributes such as `aria-label`, `role`, and `aria-hidden` are helpful for enhancing accessibility, but they can be misused if applied incorrectly. For example, using `role="button"` on a `<div>` without making it keyboard accessible is not a good solution. It might make a `<div>` act like a button for screen readers, but without proper keyboard functionality, it doesn't actually improve the user experience but rather makes it more confusing.
**How you can use ARIA the right way:**
* **Choose semantic HTML:** Always use native HTML elements like `<button>`, `<nav>`, and `<header>` because they come with built-in accessibility features. For instance, a `<button>` is already focusable and can be activated with the keyboard.
* **Use ARIA only when necessary:** ARIA should be used only when there's no semantic HTML alternative. For example, use `aria-label` only when the label is not visually present, but avoid it when a proper `<label>` tag exists.
* **Test with screen readers:** After adding ARIA attributes, always test them with screen readers like JAWS or NVDA to ensure they provide meaningful and accurate descriptions. ARIA should enhance accessibility, not decrease it.
#### **5\. Missing Captions and Transcripts for Multimedia**
If your website contains videos or audio content and misses captions or transcripts, it can exclude people with hearing impairments. Even auto-generated captions from services like YouTube can be inaccurate or miss essential context, especially with technical jargon or heavy accents.
**How you can ensure accessibility in multimedia:**
* **Captions:** Ensure all videos, whether embedded or hosted on your site, have accurate captions. You can use tools like WebVTT or YouTube’s manual captioning feature to provide these. Captions should sync correctly with the dialogue and include relevant background sounds or music.
* **Provide transcripts:** For podcasts or audio content, always provide a transcript that users can read. This not only benefits hearing-impaired users but also makes your content more accessible to non-native speakers or anyone who prefers reading.
* **Control and customization:** Make sure that users can easily toggle captions on/off and adjust their settings, like font size or color, to match their needs.
```
<video width="320" height="240">
<source type="video/mp4" src="/my_video_file.mp4" />
<track src="/captions_file.vtt" label="English" kind="captions" srclang="en-us" default="" />
<track src="/French_captions_file.vtt" label="French" kind="subtitles" srclang="fr" /></video>
```
#### **6\. What About Mobile Accessibility?**
With the increasing use of mobile devices, it’s critical to develop with accessibility in mind for mobile users. Problems often arise with touch targets that are too small, preventing users with motor impairments from tapping accurately. Additionally, restricting zoom functionality (`user-scalable=no`) can prevent users from adjusting the text size to meet their needs.
**How you can improve mobile accessibility:**
* **Size of touch targets:** For example, according to Apple’s guidelines, touch targets like buttons, links, and form fields should be at least 44x44px. This ensures that users with motor impairments or who struggle with precision can tap buttons accurately.
* **Allow zooming:** Never disable zooming on mobile versions of websites. Users should be able to zoom in on text to make it more readable.
* **Test with screen readers:** Always test your mobile site with real mobile screen readers like VoiceOver (iOS) and TalkBack (Android) to ensure that it’s accessible, and that screen reader users can interact with the site as expected.
#### **7\. How Lazy Loading, Images, and Videos Impact Accessibility**
Lazy loading is a great way to improve performance, but it can be problematic for screen reader users. When images are set to load lazily (with `loading="lazy"`), screen readers may not detect the image until it enters the viewport, potentially confusing the users. Additionally, placeholder content, such as skeleton loaders, can confuse assistive technology users if they are not properly labeled with ARIA attributes. Autoplaying videos are also a problem by starting without user interaction, which can be disruptive for screen reader users who may not have control over playback.
**How you can fix it:**
* **Prioritize important images:** Avoid lazy loading on essential images (such as logos or key UI elements) that users need immediately. Let these load first to avoid delays in critical visual content.
* **Use `aria-live` for dynamically loaded content:** If your site loads content dynamically (e.g., infinite scroll), use `aria-live` regions to notify screen readers when new content appears. This way, assistive technologies will announce new content to users.
* **Autoplay videos:** Always provide user controls to start, stop, and adjust video playback. You should avoid autoplay unless it’s absolutely necessary, as it can start playing without warning, disrupting users, especially those relying on screen readers.
###
###
Accessibility isn’t something you make or fix once and forget about. It’s an ongoing commitment to making your website better for every user. By tackling accessibility issues, you’re improving user experience, SEO, and ensuring your site reaches a wider audience.
As a front-end developer, you should incorporate accessibility into your workflow rather than just doing it for the requirement. Regular audits will help with those sneaky issues you might miss. And remember, building accessible websites means building a better web for everyone.
Last but not least, for a topic of microcopy and other accessibility techniques of UX writing check out our article Accessible UX Writing: Microcopy, Alt-Text, and Screen Readers.
Antonio is a Web Developer at COBE who likes pixel-perfect designs and exploring new technologies. Outside of coding, he’s a football enthusiast who also enjoys a good challenge in board and video games.