ARIA, which stands for Accessible Rich Internet Applications, is a set of attributes that can be added to HTML elements to improve web accessibility for individuals with disabilities. By incorporating ARIA into web pages, developers can enhance the experience for users who rely on assistive technologies, such as screen readers, to access and interact with web content.

1. ARIA Landmarks

ARIA Landmarks provide a way to identify and label sections of a web page, making it easier for screen reader users to navigate through the content. These landmarks define the regions of a page, such as header, navigation, main content, and footer.

Here are some commonly used ARIA landmarks:

  • Role: banners – Represents a region that contains the site or page title.
  • Role: navigation – Identifies the region that contains navigation elements.
  • Role: main – Represents the main content of the document.
  • Role: complementary – Defines a supporting section of the document, often used for sidebars or related content.
  • Role: contentinfo – Represents metadata or information about the main content.
  • Role: search – Indicates a region that contains a search functionality.
<header role="banner">
  
</header>

<nav role="navigation">
  
</nav>

<main role="main">
  
</main>

<aside role="complementary">
  
</aside>

<footer role="contentinfo">
  
</footer>

<div role="search">
  
</div>

2. ARIA Roles

ARIA Roles define the purpose and type of an element on a web page. They help to provide context and convey the intended functionality of an element to assistive technologies.

Here are some commonly used ARIA roles:

  • Role: button – Denotes an element that functions as a button.
  • Role: link – Represents an element that functions as a hyperlink.
  • Role: heading – Represents a heading or a title for a section of content.
  • Role: checkbox – Identifies a checkbox element.
  • Role: textbox – Indicates an input field where users can enter text.
  • Role: alert – Represents important or time-sensitive information that requires user attention.
<button role="button">
  
</button>

<a href="#" role="link">
  
</a>

<h1 role="heading">
  
</h1>

<input type="checkbox" role="checkbox">

<input type="text" role="textbox">

<div role="alert">
  
</div>

3. ARIA States and Properties

ARIA States and Properties provide additional information about the current state or properties of an element. They can be used to indicate things like whether an element is expanded or collapsed, selected or unselected, or disabled.

Here are some commonly used ARIA states and properties:

  • State: aria-expanded – Indicates whether a collapsible element is expanded or collapsed.
  • State: aria-selected – Specifies whether an item in a list or menu is currently selected.
  • State: aria-disabled – Indicates whether an element is currently disabled or not.
  • Property: aria-valuemin – Defines the minimum allowed value of a range widget.
  • Property: aria-valuemax – Defines the maximum allowed value of a range widget.
  • Property: aria-valuenow – Indicates the current value of a range widget.
<div aria-expanded="true">
  
</div>

<li aria-selected="true">
  
</li>

<button aria-disabled="true">
  
</button>

<input type="range" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50">

<progress aria-valuemin="0" aria-valuemax="100" aria-valuenow="75"></progress>

<meter aria-valuemin="0" aria-valuemax="100" aria-valuenow="25"></meter>

4. ARIA Labels and Descriptions

ARIA Labels and Descriptions are used to provide accessible names and descriptions to elements. They help to convey meaningful information to assistive technologies and enable a better understanding of the content.

The aria-label attribute allows developers to provide a concise label or description directly on an element.

The aria-labelledby attribute references the ID of another element on the page that serves as the label or description for the current element.

The aria-describedby attribute references the ID of an element that provides a detailed description or instructions for the current element.

<button aria-label="Close">
  
</button>

<div id="section-heading">
  <h2>Section Heading</h2>
</div>

<h3 aria-labelledby="section-heading">
  
</h3>

<div id="instructions">
  <p>Enter your username and password</p>
</div>

<input type="text" aria-describedby="instructions">

5. ARIA Live Regions

ARIA Live Regions are used to provide dynamic or frequently changing content updates to assistive technologies. They are particularly useful in scenarios where content updates occur without a page refresh or user interaction.

There are three main ARIA attributes used in live regions:

  • aria-live: Indicates that an element should be treated as a live region and specifies how assistive technologies should handle updates to that region.
  • aria-atomic: Defines whether assistive technologies should present the entire live region or only changes within it.
  • aria-relevant: Specifies the types of content changes that are relevant and should be announced to the user.
<div aria-live="polite" aria-atomic="true" aria-relevant="additions">
  
</div>

Why Not Use ARIA on Standard HTML Tags?

It is not necessary to use ARIA attributes on standard HTML tags when there are native HTML attributes available that serve the same purpose. For example, using the <button> element instead of a <div> with a role="button" attribute is preferred, as the <button> element already has built-in semantics and keyboard accessibility.

By using native HTML tags and attributes, you ensure better compatibility with assistive technologies and provide a more accessible experience out of the box.

Warning: Overuse of ARIA

While ARIA is a powerful tool for enhancing web accessibility, it is important to use it judiciously and avoid overusing it. Overuse of ARIA can lead to confusion, incorrect information, and a poor user experience for individuals using assistive technologies.

ARIA should be used to supplement and enhance the existing semantics of HTML, not to replace or override them. It is essential to understand the purpose and appropriate usage of each ARIA attribute to ensure that they are used in a meaningful and effective manner.

Conclusion

ARIA is a valuable set of attributes that can significantly improve web accessibility. By incorporating ARIA landmarks, roles, states, properties, labels, descriptions, and live regions into your web pages, you can create a more inclusive and user-friendly experience for individuals with disabilities.

Remember to use ARIA in conjunction with native HTML tags and attributes whenever possible, and avoid overusing ARIA to maintain clarity, compatibility, and an optimal user experience.