Enhancing Accessibility with Discernible Names

Posted on

Enhancing Web Accessibility with Discernible Names

In the digital age, ensuring that websites and applications are accessible to all users, including those with disabilities, is not just a matter of legal compliance but a reflection of inclusive design principles. One of the critical aspects of making interactive elements accessible is by providing them with discernible names. A discernible name is a piece of information that clearly describes the purpose or function of an element to users, particularly those using assistive technologies like screen readers.

Understanding Discernible Names

A discernible name is crucial for elements such as links, buttons, and icons, which perform actions or lead the user to different parts of a website or application. These names help users understand what will happen when they interact with an element. Without a discernible name, an element may be announced by a screen reader in a way that doesn't convey its purpose, leading to confusion and a frustrating user experience.

For example, consider an icon button with no text label, only a graphical representation (e.g., a magnifying glass for search). While this may be visually recognizable to sighted users, those using screen readers would encounter difficulty unless the button is properly labeled with a discernible name.

How to Add a Discernible Name

Let's take the example of an anchor tag designed as a search icon:

<a href="#" class="gmr-icon icon_search"></a>

This HTML snippet creates a clickable icon, presumably to trigger a search function, but it lacks a discernible name. To make it accessible, we can use the aria-label attribute, which provides an accessible name for assistive technologies:

<a href="#" class="gmr-icon icon_search" aria-label="Search"></a>

By adding aria-label="Search", we've now given the link a discernible name that clearly communicates its function to users who rely on assistive technologies, without changing the visual presentation of the link.

Best Practices for Using Discernible Names

  • Use Clear and Concise Language: The name should accurately describe the function of the element. Avoid using vague descriptions like "click here" or "more."
  • Consistency: Use consistent naming for elements that perform the same action across your website or application. This helps users learn and predict how to interact with your content.
  • Test with Screen Readers: To ensure your discernible names are effectively communicated, test your website with screen readers and other assistive technologies. This can help identify any elements that might be confusing or unclear.

Another way to add discernible names is:

Using visually hidden text: This method involves adding text inside the anchor tag that is visually hidden but accessible to screen readers. This can be done by applying a specific CSS class to the text that visually hides it without removing it from the screen readers' flow.

First, define a CSS class for visually hidden text:

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

Then, use this class in your HTML:

<a href="#" class="gmr-icon icon_search">
  <span class="visually-hidden">Search</span>
</a>

Both methods improve accessibility by providing a text alternative for screen readers, making your icon functionally equivalent to a text link.

Conclusion

Incorporating discernible names into web design is a vital step toward creating more accessible and user-friendly digital environments. By ensuring that all interactive elements have clear, descriptive names, designers and developers can significantly enhance the usability of their websites and applications for everyone, including those using assistive technologies. Remember, accessibility improvements like these not only help users with disabilities but also improve the overall user experience, reflecting best practices in web development and design.