ARIA: singing from the same hymn sheet πŸ’»

|

singer singing aria

Nope. Not this aria!

What is ARIA?

We’re talking about accessibility!

Accessibility refers to the creation of digital content that can be used by everyone.

The W3C documentation is not easy reading, but finally I have read through the specification and guides to understand it properly for myself.

Tell me already

If you create your own whizz-bang Date Picker, how will a screen reader know what it is?

You need to tell it. Use ARIA (Accessible Rich Internet Applications), WAI-ARIA, license to include!

james bond guessing game blindfolded

ARIA is a World Wide Web Consortium (W3C) specification with the aim of improving accessibility for modern web applications, in particular for dynamic content and custom user interface (UI) controls. It defines a set of attributes that can provide additional semantics to elements.

ARIA has no effect on how elements are displayed or behave in browsers. Its purpose is to provide extra description for Assistive Technologies (ATs) when needed.

Use Cases

The most common Use Cases for ARIA are:

  1. Assist in identifying the major regions of your page to make navigation easier (these are called landmarks);
  2. Identify and describe a custom UI control;
  3. Tell a user when you are loading dynamic content;
  4. Alert a user when something important pops up;
  5. Tell screen readers when the state of the page changes.

ARIA is our last stop for accessibility, the previous post spoke about what you should be doing already.

Rules of ARIA

The W3C made some rules to help you use ARIA properly.

The first rule of ARIA is, do not use ARIA, if possible!

These are the rules:

  1. If you can use a native HTML element or attribute with the semantics and behaviour you require already built in, then use it!

  2. Do not change native semantics, unless you really have to. If you give a div a role="button", there is no β€˜hey presto, now I am button’ moment. It does not have all of the typical keyboard events you associate with a button.

    <div role="button">Faker</button>
    
  3. All interactive ARIA controls must be usable with the keyboard. For example, if you use role=button, the element must be able to receive focus and a user must be able to activate the action associated with the element using both the enter (on WIN OS); or return (MAC OS) and space.

  4. Do not use role="presentation" or aria-hidden="true" on a focusable element .

  5. All interactive elements must have an accessible name. We must label them. We discuss it more in Labels.

Features

There are three main features of ARIA:

  • Roles β€” These define what an element is or does.
  • Properties β€” Properties are attributes that are inherent to an object. Properties are less likely to change than states, but that is not a rule. For example, aria-label="signup form" gives a form an accessible name.
  • States β€” A state is a property of an object that may change in response to user action or automated process. For example, aria-disabled="true" specifies that the element is currently disabled.

The distinction between states and properties is not great, they both are attributes prefixed with β€œaria-”. It is of little consequence to most web content authors which is which, so you may see them simply referred to as attributes. I will speak about them together later.

Labels

If you write HTML well, you probably have a label for each input and button. Nothing else needs to be done for them if you do that.

There are other cases when you need to label an element, and thats when ARIA steps in.

You may want users to be able to navigate to your form, when we add an aria-label, screen readers identify it as a landmark. We try to keep the text in the label short.

<form aria-label="product feedback">
  ... content ...
</form>

For a longer label, we can use aria-labelledby to point to a heading, or another element.

<section aria-labelledby="sect1">
  <h2 id="sect1">Product Warnings and Returns Guidelines</h2>
  ... content ...
</section>

Tell me more?

If you want me to follow up and finish this topic, let me know. Thanks for reading. 😊

Related Posts