ARIA and HTML  |  web.dev (2024)

Most developers are familiar with the standard markup language of our modernweb, HyperText Markup Language (HTML).However, you may be less familiar withAccessible Rich Internet Applications (ARIA)(formally called WAI-ARIA): what it is, how it is used, and when—and when not—to use it.

HTML and ARIA play important roles in making digital products accessible,especially when it comes to assistive technology (AT) such as screen readers.Both are used to convert content into an alternate format, such as Braille orText-to-Speech (TTS).

Let's review a short history of ARIA, why it is important, and when and howbest to use it.

Introduction to ARIA

ARIA was first developed in 2008 by theWeb Accessibility Initiative (WAI) group—asubset of the overarching World Wide Web Consortium (W3C), which governs andregulates the internet.

ARIA is not a true programming language but a set of attributes you can add toHTML elements to increase their accessibility. These attributes communicaterole, state, and property to assistive technologies via accessibility APIsfound in modern browsers. This communication happens through the accessibilitytree.

"WAI-ARIA, the Accessible Rich Internet Applications Suite, defines a way to make web content and web applications more accessible to people with disabilities. It especially helps with dynamic content and advanced user interface controls developed with HTML, JavaScript, and related technologies."

The WAI group

The accessibility tree

ARIA modifies incorrect or incomplete code to create a better experience forthose using AT by changing, exposing, and augmenting parts of the accessibilitytree.

The accessibility tree is created by the browser and based on the standardDocument Object Model (DOM) tree. Like the DOM tree, the accessibility treecontains objects representing all the markup elements, attributes, and textnodes. The accessibility tree is also used by platform-specific accessibilityAPIs to provide a representation that assistive technologies can understand.

ARIA and HTML | web.dev (1)

ARIA on its own doesn't change an element's functionality or visual appearance.That means only AT users will notice differences between a digital product withARIA and one without it. That also means that developers alone are responsiblefor making the appropriate code and styling changes to make an element asaccessible as possible.

The three main features of ARIA are roles, properties, and states/values.

Roles define what an element is or does on the page or app.

<div role="button">Self-destruct</div>

Properties express characteristics or relationships to an object.

<div role="button" aria-describedby="more-info">Self-destruct</div><div id="more-info">This page will self-destruct in 10 seconds.</div>

States/values define the current conditions or data values associated with the element.

<div role="button" aria-describedby="more-info" aria-pressed="false"> Self-destruct</div><div id="more-info"> This page will self-destruct in 10 seconds.</div>

While all three elements of ARIA can be used in one line of code, it's notrequired. Instead, layer ARIA roles, properties, and states/values until you'veaccomplished your final accessibility goal. Correctly incorporating ARIA intoyour code base ensures that AT users will have all the information they need touse your website, app, or other digital product successfully and equitably.

Recently, Chrome DevTools has created a way tosee the full accessibility treemaking it easier for developers to understand how their code impactsaccessibility.

When to use ARIA

In 2014, the W3C officially published the HTML5 recommendation. With it camesome big changes, including the addition of landmark elements such as <main>,<header>, <footer>, <aside>, <nav>, and attributes like hidden andrequired. With these new HTML5 elements and attributes, coupled withincreased browser support, certain parts of ARIA are now less critical.

When the browser supports an HTML tag with an implicit role with an ARIAequivalent, there is usually no need to add ARIA to the element. However, ARIAstill includes many roles, states, and properties that aren't available in anyversion of HTML. Those attributes remain useful for now.

This brings us to the ultimate question: When should you use ARIA? Thankfullythe WAI group has developed thefive rules of ARIA to help you decide howto make elements accessible.

Rule 1: Don't use ARIA

Yes, you read that right. Adding ARIA to an element does not inherently make itmore accessible. The WebAIM Million annual accessibility reportfound that home pages with ARIApresent averaged 70% more detected errors than those without ARIA, primarilydue to the improper implementation of the ARIA attributes.

There are exceptions to this rule. ARIA is required when an HTML elementdoesn't have accessibility support. This could be because the design doesn'tallow for a specific HTML element or the wanted feature/behavior isn'tavailable in HTML. However, these situations should be scarce.

When in doubt, use semantic HTML elements.

Rule 2: Don't add (unnecessary) ARIA to HTML

In most circ*mstances, HTML elements work well out of the box and do not need additional ARIA added to them. In fact, developers using ARIA often have to add additional code to make the elements functional in the case of interactive elements.

Don't

<h2 role="tab">Heading tab</h2>

Do

<div role="tab"><h2>Heading tab</h2></div>

Do less work and have better-performing code when you use HTML elements asintended.

Rule 3: Always support keyboard navigation

All interactive (not disabled) ARIA controls must be keyboard accessible. Youcan add tabindex= "0" to any element that needs a focus that doesn't normallyreceive keyboard focus. Avoid using tab indexes with positiveintegerswhenever possible to prevent potential keyboard focus order issues.

Don't

<span role="button" tabindex="1">Submit</span>

Do

<span role="button" tabindex="0">Submit</span>

Of course, if you can, use a real <button> element in this case.

Rule 4: Don't hide focusable elements

Don't add role= "presentation" or aria-hidden= "true" to elements that needto have focus—including elements with a tabindex= "0". When you addthese roles/states to elements, it sends a message to the AT that theseelements are not important and to skip over them. This can lead to confusion ordisrupt users attempting to interact with an element.

Don't

<div aria-hidden="true"><button>Submit</button></div>

Do

<div><button>Submit</button></div>

Rule 5: Use accessible names for interactive elements

The purpose of an interactive element needs to be conveyed to a user beforethey know how to interact with it. Ensure that all elements have anaccessible name for people using ATdevices.

Accessible names can be the content surrounded by an element (in the case of an<a>), alternative text, or a label.

For each of the following code samples, the accessible name is "Red leatherboots."

<!-- A plain link with text between the link tags. --><a href="shoes.html">Red leather boots</a><!-- A linked image, where the image has alt text. --><a href="shoes.html"><img src="shoes.png" alt="Red leather boots"></a><!-- A checkbox input with a label. --><input type="checkbox" id="shoes"><label for="shoes">Red leather boots</label>

There are many ways to check an element's accessible name, including inspecting the accessibility tree using Chrome DevTools or testing it with a screen reader.

ARIA in HTML

While using HTML elements on their own is best practice, ARIA elements can beadded in certain situations. For example, you may pair ARIA with HTML inpatterns that need a higher level of AT support because of environmentalconstraints or as a fall-back method for HTML elements that aren't fullysupported by all browsers.

Of course, there are recommendations for implementing ARIA inHTML. Most importantly: don't overridedefault HTML roles, reduce redundancy, and be aware of unintended side effects.

Let's look at some examples.

Don't

<a role="heading">Read more</a>

Assigned the wrong role.

Do

<a aria-label="Read more about some awesome article title">Read More</a>

Correct role and an extra link description.

Don't

<ul role="list">...</ul>

Redundant role.

Do

<ul>...</ul>

Redundancy removed

Don't

<details> <summary role="button">more information</summary> ...</details>

Potential side effects.

Do

<details> <summary>more information</summary> ...</details>

No unintended side effects.

Complexities of ARIA

ARIA is complex, and you should always use caution when using it. While thecode examples in this lesson are fairly straightforward, creating accessiblecustom patterns can quickly get complicated.

There are many things to pay attention to, including but not limited to:keyboard interactions, touch interfaces, AT/browser support, translation needs,environmental constraints, legacy code, and user preferences. A little bit ofcoding knowledge can be detrimental—or just plain annoying—if usedincorrectly. Remember to keep your code simple.

Those warnings aside, digital accessibility is not an all-or-nothingsituation—it's a spectrum that allows for some gray areas like this.Multiple coding solutions can be seen as "correct," depending on the situation.What is important is that you keep learning, testing, and trying to make ourdigital world more open to all.

Check your understanding

Test your knowledge of ARIA and HTML

Which of the following is the best practice for building an accessible button?

<div id="saveChanges" aria-role="button" aria-pressed="false" tabindex="0">Go to shop</div>

Not quite. ARIA shouldn't be used when a semantic HTML element is available.

<a id="saveChanges" aria-label="Some awesome article title">Go to shop</a>

Not quite. While you could style this link like a button with CSS, it's not the best practice.

<button id="saveChanges" type="button">Go to shop</button>

Great job! Use the correct semantic HTML as well as the type to create a button.

ARIA and HTML  |  web.dev (2024)

FAQs

What is aria in web dev? ›

ARIA is shorthand for Accessible Rich Internet Applications. ARIA is a set of attributes you can add to HTML elements that define ways to make web content and applications accessible to users with disabilities who use assistive technologies (AT).

What is the difference between HTML and aria? ›

In general, aria-* attributes are useful to convey important information to assistive technologies about custom controls or complex interactions. HTML attributes can directly impact features and functionality.

What is the aria role in HTML? ›

ARIA roles can be used to describe elements that don't natively exist in HTML or exist but don't yet have full browser support. By default, many semantic elements in HTML have a role; for example, <input type="radio"> has the "radio" role.

Why use aria label in HTML? ›

Description. The purpose of this technique is to provide a label for objects that can be read by assistive technology. The aria-label attribute provides the text label for an object, such as a button. When a screen reader encounters the object, the aria-label text is read so that the user will know what it is.

Is aria part of HTML? ›

ARIA is not a true programming language but a set of attributes you can add to HTML elements to increase their accessibility.

Do you need aria HTML? ›

The first rule of ARIA use is "If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so." Note: There is a saying "No ARIA is better than bad ARIA."

What is aria required in HTML? ›

The WAI-ARIA aria-required property indicates that user input is required before submission. The aria-required property can have values of "true" or "false". For example, if a user must fill in an address field, then aria-required is set to "true".

What is aria controls HTML? ›

The aria-controls attribute creates a cause and effect relationship. It identifies the element(s) that are controlled by the current element. The "aria-controls" element should be a "button" or a "link". It still not really necessary to use a specific context formatting for your XHTML markup.

What is the difference between semantic HTML and aria? ›

Semantic HTML provides meaning and structure to content, enabling browsers, search engines, screen readers, and users to understand and interact with websites effectively. ARIA complements HTML semantics by enhancing the accessibility of dynamic interactions.

What is the aria value in HTML? ›

aria-valuetext provides a way of presenting the current value in a more user-friendly, human-understandable way. For example, a battery meter value might be conveyed as aria-valuetext="8% (34 minutes) remaining" .

What is the use of aria hidden in HTML? ›

Yes, the aria-hidden attribute is used to hide elements visually. It is an accessibility attribute that tells screen readers and other assistive technologies to ignore or hide the element from the user. When an element has aria-hidden="true" , it will not be presented to screen reader users.

What is aria checked in HTML? ›

The ariaChecked property of the Element interface reflects the value of the aria-checked attribute, which indicates the current "checked" state of checkboxes, radio buttons, and other widgets that have a checked state.

What is aria software used for? ›

ARIA oncology information system supports medical and radiation oncology, including proton therapy. Review clinical images, prescriptions, lab results, QA, outcomes, and more. Automate cancer staging based on AJCC guidelines and manage toxicities flexibly.

What does aria stand for? ›

ARIA is a W3C specification that stands for “Accessible Rich Internet Applications.” It consists of markup that can be added to HTML in order to communicate the roles, states, and properties of user interface elements to assistive technologies (AT).

Is aria good for SEO? ›

Proper use of ARIA (Accessible Rich Internet Applications) labels and roles, along with structured content and headings, can significantly improve both accessibility and SEO. By focusing on improving site accessibility for SEO, webmasters can ensure their sites are both user-friendly and search engine optimized.

What is aria controls used for? ›

The aria-controls attribute creates a cause and effect relationship. It identifies the element(s) that are controlled by the current element. The "aria-controls" element should be a "button" or a "link". It still not really necessary to use a specific context formatting for your XHTML markup.

Top Articles
Nvidia’s rise echoes Tesla’s 2020 rally, giving investors pause
Nvidia Up 80% This Year, Which Ai Project Choose to Invest in?
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Dr. Pierre Goyette

Last Updated:

Views: 5786

Rating: 5 / 5 (50 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Dr. Pierre Goyette

Birthday: 1998-01-29

Address: Apt. 611 3357 Yong Plain, West Audra, IL 70053

Phone: +5819954278378

Job: Construction Director

Hobby: Embroidery, Creative writing, Shopping, Driving, Stand-up comedy, Coffee roasting, Scrapbooking

Introduction: My name is Dr. Pierre Goyette, I am a enchanting, powerful, jolly, rich, graceful, colorful, zany person who loves writing and wants to share my knowledge and understanding with you.