Web Accessibility / Advanced Web Accessibility Techniques

Advanced Use of ARIA for Dynamic Content

In this tutorial, you'll learn about the advanced use of Accessible Rich Internet Applications (ARIA) for dynamic web content. ARIA attributes provide additional semantics to help…

Tutorial 2 of 5 5 resources in this section

Section overview

5 resources

Explores advanced techniques and strategies to build highly accessible web applications.

Advanced Use of ARIA for Dynamic Content

1. Introduction

Goal:

The goal of this tutorial is to teach you how to use Accessible Rich Internet Applications (ARIA) in advanced ways to manage dynamic content on your web pages.

Learning Outcomes:

You will learn how to use ARIA roles, states, and properties to make your dynamic web content more accessible. You will also learn how to implement ARIA live regions to manage updates and changes in content.

Prerequisites:

You should have a basic understanding of HTML, CSS, JavaScript, and a general understanding of how ARIA works.

2. Step-by-Step Guide

ARIA Roles:

ARIA roles provide information about what an element is or does. For dynamic content, roles such as alert, log, status, and progressbar can be used.

Example:

<div role="alert">This is an important message!</div>

ARIA States and Properties:

ARIA states and properties provide additional information about an element's current condition or characteristics. For instance, aria-hidden, aria-expanded, and aria-busy can be used for dynamic content.

Example:

<button aria-expanded="false">Menu</button>

ARIA Live Regions:

ARIA live regions allow assistive technologies to understand when a part of the web page updates. This is very useful for dynamic content. aria-live can have values like off, polite, and assertive.

Example:

<div aria-live="polite">This content will update.</div>

3. Code Examples

Example 1: Using aria-expanded

<!-- The button that controls the expanding and collapsing -->
<button id="expander" aria-expanded="false" onclick="toggleContent()">Toggle Content</button>

<!-- The content that expands and collapses -->
<div id="content" aria-hidden="true">This is the content that will be toggled.</div>

<script>
  function toggleContent() {
    const content = document.getElementById('content');
    const expander = document.getElementById('expander');
    const isExpanded = expander.getAttribute('aria-expanded') === 'true';

    // Toggle the 'aria-hidden' attribute
    content.setAttribute('aria-hidden', isExpanded);

    // Toggle the 'aria-expanded' attribute
    expander.setAttribute('aria-expanded', !isExpanded);
  }
</script>

Example 2: Using aria-live

<!-- The live region -->
<div id="live-region" aria-live="polite">Waiting for updates...</div>

<script>
  function updateContent() {
    const liveRegion = document.getElementById('live-region');

    // Update the live region
    liveRegion.textContent = 'Content updated at ' + new Date().toLocaleTimeString();
  }

  // Update the content every second
  setInterval(updateContent, 1000);
</script>

4. Summary

In this tutorial, we learned about advanced ARIA techniques for dynamic web content. We discussed ARIA roles, states, properties, and live regions.

Continue learning about ARIA by studying other roles, states, and properties, and how they can be used to improve accessibility. You can find more information in the WAI-ARIA Authoring Practices.

5. Practice Exercises

  1. Create a web page with a progress bar that updates every second. Use the progressbar role and the aria-valuenow property to indicate the current progress.

  2. Create a web page with a dropdown menu. Use the menu and menuitem roles and the aria-expanded state to manage the dropdown.

  3. Create a web page with a live chat interface. Use a live region to announce new messages.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Favicon Generator

Create favicons from images.

Use tool

PDF Password Protector

Add or remove passwords from PDF files.

Use tool

Random Password Generator

Create secure, complex passwords with custom length and character options.

Use tool

Word to PDF Converter

Easily convert Word documents to PDFs.

Use tool

JavaScript Minifier & Beautifier

Minify or beautify JavaScript code.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help