Introduction to ARIA  |  Articles  |  web.dev (2024)

Introduction to ARIA and non-native HTML semantics

So far, we've encouraged using native HTML elements because they give you focus,keyboard support, and built-in semantics, but there are times when a simplelayout and native HTML won't do the job. For example, currently there's nostandardized HTML element for a very common UI construct, the pop-up menu. Noris there an HTML element that provides a semantic characteristic such as "theuser needs to know about this as soon as possible".

In this lesson, then, we'll explore how to express semantics that HTML can'texpress on its own.

The Web Accessibility Initiative's Accessible Rich Internet Applicationsspecification (WAI-ARIA, or justARIA) is good for bridging areas with accessibility issues that can't be managedwith native HTML. It works by allowing you to specify attributes that modify theway an element is translated into the accessibility tree. Let's look at anexample.

In the following snippet, we use a list item as a kind of custom checkbox. TheCSS "checkbox" class gives the element the required visual characteristics.

<li tabindex="0" class="checkbox" checked> Receive promotional offers</li>

While this works fine for sighted users, a screen reader will give no indicationthat the element is meant to be a checkbox, so low-vision users may miss theelement entirely.

Using ARIA attributes, however, we can give the element the missing informationso the screen reader can properly interpret it. Here, we've added the role andaria-checked attributes to explicitly identify the element as a checkbox andto specify that it is checked by default. The list item will now be added to theaccessibility tree and a screen reader will correctly report it as a checkbox.

<li tabindex="0" class="checkbox" role="checkbox" checked aria-checked="true"> Receive promotional offers</li>

ARIA works by changing and augmenting the standard DOM accessibility tree.

Introduction to ARIA | Articles | web.dev (4)
Introduction to ARIA | Articles | web.dev (5)

Although ARIA allows us to subtly (or even radically) modify the accessibilitytree for any element on the page, that is the only thing it changes. ARIAdoesn't augment any of the element's inherent behavior; it won't make theelement focusable or give it keyboard event listeners. That is still part of ourdevelopment task.

It's important to understand that there is no need to redefine defaultsemantics. Regardless of its use, a standard HTML <input type="checkbox">element doesn't need an additional role="checkbox" ARIA attribute to becorrectly announced.

It's also worth noting that certain HTML elements have restrictions on what ARIAroles and attributes can be used on them. For example, a standard <inputtype="text"> element may not have any additional role/attribute applied to it.

See the ARIA in HTML specfor more information.

Let's see what other capabilities ARIA has to offer.

What can ARIA do?

As you saw with the checkbox example, ARIA can modify existing element semanticsor add semantics to elements where no native semantics exist. It can alsoexpress semantic patterns that don't exist at all in HTML, like a menu or a tabpanel. Often, ARIA lets us create widget-type elements that wouldn't be possiblewith plain HTML.

  • For example, ARIA can add extra label and description text that is onlyexposed to assistive technology APIs.
<button aria-label="screen reader only label"></button>
  • ARIA can express semantic relationships between elements that extend thestandard parent/child connection, such as a custom scrollbar that controls aspecific region.
 <div role="scrollbar" aria-controls="main"></div> <div id="main"> . . . </div>
  • And ARIA can make parts of the page "live," so they immediately informassistive technology when they change.
 <div aria-live="polite"> <span>GOOG: $400</span> </div>

One of the core aspects of the ARIA system is its collection of roles. A rolein accessibility terms amounts to a shorthand indicator for a particular UIpattern. ARIA provides a vocabulary of patterns we can use via the roleattribute on any HTML element.

When we applied role="checkbox" in the previous example, we were tellingassistive technology that the element should follow the "checkbox" pattern. Thatis, we're guaranteeing that it will have a checked state (either checked or notchecked), and that the state may be toggled using the mouse or the spacebar,just like a standard HTML checkbox element.

In fact, because keyboard interactions feature so prominently in screen readerusage, it's very important to make sure that, when creating a custom widget, therole attribute is always applied in the same place as the tabindexattribute; this ensures that keyboard events go to the right place and that whenfocus lands on an element its role is conveyed accurately.

The ARIA spec describes ataxonomy of possible values for the role attribute and associated ARIAattributes that may be used in conjunction with those roles. This is the bestsource of definitive information about how the ARIA roles and attributes worktogether and how they can be used in a way that is supported by browsers andassistive technologies.

Introduction to ARIA | Articles | web.dev (6)

However, the spec is very dense; a more approachable place to start is the ARIAAuthoring Practices document, which explores best practices for using the available ARIA roles andproperties.

ARIA also offers landmark roles that extend the options available in HTML5. Seethe Landmark Roles DesignPatternsspec for more information.

Introduction to ARIA  |  Articles  |  web.dev (2024)
Top Articles
Marcellos Berkeley Heights
I Tested D'Alba's Aromatic Spray Serum and Here's Why It's My New Go-To Skincare Essential
Basketball Stars Unblocked 911
Google Jobs Denver
Greet In Cheshire Crossword Clue
Best Transmission Service Margate
Eso Mud Ball Miscreant
Chars Boudoir
Vivek Flowers Chantilly
Log in or sign up to view
Gay Black Scat
24 Hour Lock Up Knoxville Tn
Palos Health My Chart
Craigslist Rooms For Rent North County San Diego
Syoss Oleo Intense - 5-10 Cool Bruin - Permanente Haarverf - Haarkleuring - 1 stuk | bol
Usccb 1 John 4
What To Do With Mysterious Camera In Sakura Stand
Katonah Train Times
Costco Gas Price City Of Industry
Friend Offers To Pay For Friend’s B-Day Dinner, Refuses When They See Where He Chose
Coleman Funeral Home Olive Branch Ms Obituaries
Dimbleby Funeral Home
Hmr Properties
Watch Fifty Shades Darker Online Putlocker
Sunset On November 5 2023
Violent Night Showtimes Near Santikos Entertainment Mayan Palace
Dumb Money Showtimes Near Showcase Cinema De Lux Legacy Place
Uganda: The tiny flea making it painful for people to walk and work | African Arguments
Anna Shumate Leaks
Pella Culver's Flavor Of The Day
Gopher Hockey Forum
Orbison Roy: (1936 1988) American Singer. Signed 7 X 9
Banning Beaumont Patch
Hyb Urban Dictionary
SimpliSafe Home Security Review: Still a Top DIY Choice
Help with Finding Parts for Your Vehicle
Kare11.Com Contests
Camila Arujo Leaks
Shs Games 1V1 Lol
Rs3 Bis Perks
Unblocked Games 76 Bitlife
Top 100 Golfclubs - Albrecht Golf Guide bei 1Golf.eu
Son Blackmailing Mother
Dom Tradingview
Skagit.craigslist
Agurahl The Butcher Wow
Blood Types: What to Know
Sdn Michigan State Osteopathic 2023
Nfl Spotrac Transactions
Lanipopvip
Lottozahlen für LOTTO 6aus49 | LOTTO Bayern
Twisted Bow Osrs Ge Tracker
Latest Posts
Article information

Author: Jamar Nader

Last Updated:

Views: 5855

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.