diff --git a/src/_data/authors.json b/src/_data/authors.json index e90178b2f..531729e72 100644 --- a/src/_data/authors.json +++ b/src/_data/authors.json @@ -229,11 +229,18 @@ "biography": "Founder of MadHackerHaus and Rolled Up Sleeves, LLC. Advocate for accessibility in developing the internet and mobile technology." }, { - "name": "Rachel R. Vasquez", - "first": "Rachel", - "website": "http://rachievee.com", - "photo": "https://avatars0.githubusercontent.com/u/10246844?s=460&v=4", - "biography": "Senior WordPress Developer." + "name": "Nat Tarnoff", + "first": "Nat", + "website": "http://tarnoff.info/", + "photo": "https://pbs.twimg.com/profile_images/855580021951537152/bS14U2d5_400x400.jpg", + "biography": "Founder of MadHackerHaus and Rolled Up Sleeves, LLC. Advocate for accessibility in developing the internet and mobile technology." + }, + { + "name": "Paul McFedries", + "first": "Paul", + "website": "https://paulmcfedries.com", + "photo": "https://avatars.githubusercontent.com/u/7156439?s=200&v=4", + "biography": "Author of more than 100 technical books, including Web Design Playground, Web Coding and Development All-in-One For Dummies, and HTML, CSS, and JavaScript All-in-One For Dummies." }, { "name": "Rian Rietveld", diff --git a/src/img/posts/ajax-with-aria-live/aria-live-region-with-voiceover-text.png b/src/img/posts/ajax-with-aria-live/aria-live-region-with-voiceover-text.png new file mode 100644 index 000000000..1a5ed8ebf Binary files /dev/null and b/src/img/posts/ajax-with-aria-live/aria-live-region-with-voiceover-text.png differ diff --git a/src/posts/ajax-with-aria-live.md b/src/posts/ajax-with-aria-live.md new file mode 100644 index 000000000..91dc7d1e8 --- /dev/null +++ b/src/posts/ajax-with-aria-live.md @@ -0,0 +1,120 @@ +--- +title: Using Ajax with ARIA live regions +description: How to set up ARIA live regions so that assistive technologies can announce when dynamic content is added to the page via an Ajax call. +category: How-to +author: Paul McFedries +date: 2023-03-29 +tags: + - howto +--- + +Many web pages avoid page reloads by using Ajax calls to retrieve dynamic content from a server and display that content on the page. Sighted users can see the new content, but assistive technologies cannot. + +To ensure all your readers can view your dynamic content, you need to configure the region where that content appears as an ARIA live region. This article tells you everything you need to know. + +## The problem: assistive technology doesn't announce dynamic content + +When a person using assistive technology (AT) such as a screen reader first visits a web page, the AT parses the page and creates an accessibility tree for the page structure and content. By default, the AT only updates that accessibility tree on a page reload. This means that if your page has a script that uses Ajax to retrieve new content from a server and display that content on the page, the AT has no default mechanism for announcing the new content. + +## The solution: live regions + +Fortunately, there are ways to work around this limitation. For example, one way to enable an AT to announce dynamic page content is to use the `role` attribute to set up an element as a *live region*. This is a page region that the AT monitors for changes and announces any new or changed content to the user. By default, any of the following `role` attribute values specify an element as a live region: `alert`, `log`, `marquee`, `status`, or `timer`. + +However, not every region with dynamic content falls neatly into one of these roles. When you have a `div` or other element that doesn’t fit any of the live-region roles, you can still configure the element as a live region by using the `aria-live` attribute. + +## Understanding the `aria-live` values + +The `aria-live` attribute can take one of the following three values: + +- `aria-live="polite"` Configures the element as a live region, but only announces new or changed dynamic content when the user is idle. +- `aria-live="assertive"` Configures the element as a live region, and will interrupt whatever task the user is currently performing to announce new or changed dynamic content. +- `aria-live="off"` Configures the element to not act as a live region. This is the default for all elements, but can be useful if you want to override a `role` attribute that has an implicit `aria-live` value. + +**Note:** It’s best to stick with `aria-live="polite"` because it’s the least intrusive for the user. Only use `aria-live="assertive"` if the dynamic content you're adding is extremely important. + +Here’s an example: + +```html +