Angular
Search…
ARIA
Accessible Rich Internet Applications (ARIA) is a set of attributes that define ways to make web content and web applications (especially those developed with JavaScript) more accessible to people with disabilities.
ARIA enables developers to describe their widgets in more detail by adding special attributes to the markup. Designed to fill the gap between standard HTML tags and the desktop-style controls found in dynamic web applications, ARIA provides roles and states that describe the behavior of most familiar UI widgets.
Here's the markup for a progress bar widget:
1
<div id="percent-loaded" role="progressbar" aria-valuenow="75"
2
aria-valuemin="0" aria-valuemax="100">
3
</div>
Copied!
This progress bar is built using a <div>, which has no meaning. Unfortunately, there isn't a more semantic tag available to developers in HTML 4, so we need to include ARIA roles and properties. These are specified by adding attributes to the element. In this example, the role="progressbar" attribute informs the browser that this element is actually a JavaScript-powered progress bar widget. The aria-valuemin and aria-valuemax attributes specify the minimum and maximum values for the progress bar, and the aria-valuenow describes the current state of it and therefore must be kept updated with JavaScript.
Along with placing them directly in the markup, ARIA attributes can be added to the element and updated dynamically using JavaScript code like this:
1
// Find the progress bar <div> in the DOM.
2
var progressBar = document.getElementById("percent-loaded");
3
4
// Set its ARIA roles and states,
5
// so that assistive technologies know what kind of widget it is.
6
progressBar.setAttribute("role", "progressbar");
7
progressBar.setAttribute("aria-valuemin", 0);
8
progressBar.setAttribute("aria-valuemax", 100);
9
10
// Create a function that can be called at any time to update
11
// the value of the progress bar.
12
function updateProgress(percentComplete) {
13
progressBar.setAttribute("aria-valuenow", percentComplete);
14
}
Copied!
Last modified 1yr ago
Copy link