liveBook · Manning

ARIA role

As explained in Architecting Accessibility

An ARIA role is a semantic classification assigned to an interface element to communicate its widget or structural type to assistive technologies.

An ARIA role identifies an interface element’s widget or structural type for assistive technologies. Prefer semantic HTML when it provides the needed meaning; a role describes an element but does not supply its behavior. section 2.5.2 section 5.2

When a custom interface needs ARIA roles:

  • Use the appropriate roles and implement expected keyboard interaction and focus management. section 2.5.2
  • For landmarks, use native semantic elements where possible; use ARIA roles to replicate their meaning when native HTML cannot be used. section 5.2
  • Test with a keyboard and screen reader; ARIA attributes alone do not make a component accessible. section 2.5.2
Listing 2.2 Tabbed interface implemented in HTML, including ARIA attributes
...
<main>
  <section class="tabs">
    <!-- TABS -->
    <div role="tablist" #A
      aria-label="Product Specifications"
      id="specs-tabs">
        <button type="button" role="tab" #B
          aria-selected="true" #C
          aria-controls="panel-1" #D
          id="tab-1" 
          tabindex="0"> #E
            Overview
        </button>
        <button type="button" role="tab"
          aria-selected="false" 
          aria-controls="panel-2" 
          id="tab-2" 
          tabindex="-1"> #F
            Technical Specifications
        </button>
    </div>
    <!-- PANELS -->
    <div role="tabpanel" #G
      id="panel-1"
      tabindex="0" #H
      aria-labelledby="tab-1"> #I
        <p>
          This product is lovely, durable and designed for 
          something - not sure yet. Comes with a 25-year 
          all-in warranty.
        </p>
        <p>
          This is a <a href="#">focusable</a> element.
        </p>
        <img src="images/TabInterface.jpg" 
          alt="Close up of red object" 
          class="product_image" />
     </div>
     <div role="tabpanel" 
       id="panel-2" 
       tabindex="0"
       aria-labelledby="tab-2" 
       hidden> #J
         <ul>
           <li>Dimensions: 100 × 200 × 15mm</li>
           <li>Weight: 15Kg</li>
         </ul>
     </div>
   </section>
 </main> 
...

A tabbed interface uses roles such as tablist and tab to identify its custom controls; those roles must accompany the expected interaction behavior. section 2.5.2

How Architecting Accessibility covers it

How deep it goes
Explains roles as semantic descriptions, not behavior; keyboard interaction and focus management remain implementation work.
Examples
Uses tablist and tab roles in a product-specifications interface, and landmark roles when native HTML cannot provide the semantics.
What it assumes
Assumes familiarity with semantic HTML and favors native elements before using ARIA to supply missing semantics.
What you can do after
Apply roles to custom interfaces while implementing expected behavior and testing with a keyboard and screen reader.
How it connects
Connects ARIA roles with semantic HTML, assistive technology, keyboard interaction, and focus management.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.