HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class=container>
<h1>
Live region demos
</h1>
<p>Last updated Nov 29, 2021</p>
<p>For more context on this test page, see also <a href="https://www.scottohara.me/blog/2022/02/05/are-we-live.html">Are we live? blog post</a>.</p>
<div role=note>
<p><strong>Notes:</strong></p>
<p>1. a <code>role=none</code> was added to <code><div></code>s injected into live regions so that Narrator, when paired with Chrome, would announce the injected content instead of just announcing "group" or "group" and then the text content of the live region. However, it was discovered in re-testing that this also resulted in re-announcing prior messages that weren't cleared out in live regions.</p>
<p>2. Tests were performed with the latest versions of screen readers and browsers available as of the indicated "last updated" date.</p>
</div>
<section>
<h2>Polite Demos</h2>
<h3>1p. Inject a live region</h3>
<p>Injects a <code><div aria-live=polite></code> into an empty <code><div></code>
<p>Expectation: only one announcement of the injected content, if any at all.</p>
<button id=f>Demo 1p</button>
<div id=heyo></div>
<div class=table-container>
<table>
<caption>Demo 1p - Pass: 7, Warn: 0, Fail: 10</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="no">No announcement</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="no">No announcement</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>2p. Inject content *into* a generic live region</h3>
<p>Injects content, within a <code><div role=none></code> into a <code><div aria-live=polite></code>.
<p>Expectation: only one announcement of the injected content.</p>
<button id=g>Demo 2p</button>
<div id=heyo_but_really aria-live=polite></div>
<div class=table-container>
<table>
<caption>Demo 2p - Pass: 7, Warn: 9, Fail: 1</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class=warn>Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class=warn>Yes, but additional presses no</td> <!-- jaws -->
<td class=warn>Yes, but additional presses no</td> <!-- nvda -->
<td class=warn>Yes, but additional presses no</td> <!-- narrator -->
<td class=warn>Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class=warn>Yes, but additional presses no</td> <!-- jaws -->
<td class=warn>Yes, but additional presses no</td> <!-- nvda -->
<td class="warn">Yes, but additional presses no</td> <!-- narrator -->
<td class=warn>Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>3p 1. Keep injecting content *into* a status live region</h3>
<p>Injects content, within a <code><div role=none></code> into a <code><div role=status aria-atomic=false></code>.</p>
<p>Expectation: each injection of content announced, but only the new content.</p>
<button id=s>Demo 3p 1</button>
<div id=statuso role=status aria-atomic=false></div>
<div class=table-container>
<table>
<caption>Demo 3p 1 - Pass: 9, Warn: 0, Fail: 8</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement (if changed to aria-live, announcements would be made, but it would incorrectly announce all previously exposed content as well)</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>3p 2. Keep injecting content *into* a status live region</h3>
<p>Injects content, within a <code><p></code> into a <code><div role=status aria-atomic=false></code>.</p>
<p>Expectation: each injection of content announced, but only the new content.</p>
<button id=sp2>Demo 3p 2</button>
<div id=sp2re role=status aria-atomic=false></div>
<div class=table-container>
<table>
<caption>Demo 3p 2 - Pass: 12, Warn: 1, Fail: 4</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="warn">Doesn't announce 1st message, but will announce subsequent messages.</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>4p. Keep injecting content *into* a status live region, replacing previous content</h3>
<p>Injects content, within a <code><div role=none></code> into a <code><div role=status></code>.</p>
<p>Expectation: each injection of content announced, but only the new content.</p>
<button id=r>Demo 4p</button>
<div id=rstatus role=status></div>
<div class=table-container>
<table>
<caption>Demo 4p - Pass: 15, Warn: 0, Fail: 2</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes (see group note)</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
</section>
<section>
<h2>Assertive Demos</h2>
<h3>1a. Inject a live region</h3>
<p>Injects a <code><div aria-live=assertive></code> into an empty <code><div></code>
<p>Expectation: only one announcement of the injected content, if any at all.</p>
<button id=f2>Demo 1a</button>
<div id=heyo2></div>
<div class=table-container>
<table>
<caption>Demo 1a - Pass: 7, Warn: 0, Fail: 10</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="no">No announcement</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="no">No announcement</td> <!-- jaws -->
<td class="no">No announcement</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>2a. Inject content *into* a generic live region</h3>
<p>Expectation: only one announcement of the injected content.</p>
<button id=g2>Demo 2a</button>
<div id=heyo_but_really2 aria-live=assertive></div>
<div class=table-container>
<table>
<caption>Demo 2a - Pass: 6, Warn: 10, Fail: 1</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="warn">Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="warn">Yes, but additional presses no</td> <!-- jaws -->
<td class="warn">Yes, but additional presses no</td> <!-- nvda -->
<td class="warn">Yes, but additional presses no (see group note)</td> <!-- narrator -->
<td class="warn">Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="warn">Yes, but additional presses no</td> <!-- jaws -->
<td class="warn">Yes, but additional presses no</td> <!-- nvda -->
<td class="warn">Yes, but additional presses no</td> <!-- narrator -->
<td class="warn">Yes, but additional presses no</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="warn">Yes, but additional presses no</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>3a. Keep injecting content *into* a status live region</h3>
<p>Injects content, within a <code><div role=none></code> into a <code><div role=alert aria-atomic=false></code>.</p>
<p>Expectation: each injection of content announced, but only the new content.</p>
<button id=s2>Demo 3a</button>
<div id=statuso2 role=alert aria-atomic=false></div>
<div class=table-container>
<table>
<caption>Demo 3a - Pass: 8, Warn: 0, Fail: 9</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="no">No: announces "alert" and announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces "alert" and announces previous content as well as new messages.</td> <!-- nvda -->
<td class="no">No: announces "alert" and announces previous content as well as new messages and "edit"</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<h3>4a. Keep injecting content *into* a alert live region, replacing previous content</h3>
<p>Injects content, within a <code><div role=none></code> into a <code><div role=alert></code>.
<p>Expectation: each injection of content announced, but only the new content.</p>
<button id=r2>Demo 4a</button>
<div id=rstatus2 role=alert></div>
<div class=table-container>
<table>
<caption>Demo 4a - Pass: 16, Warn: 0, Fail: 1</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes (and announces "alert" prior to text)</td> <!-- jaws -->
<td class="yes">Yes (and announces "alert" prior to text)</td> <!-- nvda -->
<td class="yes">Yes (see group note. also announces 'edit')</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No announcement</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes (see group note)</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
</section>
<section>
<h2>5. aria-live=polite aria-atomic=false test</h2>
<p>Testing three different injection methods with one live region type</p>
<p>All tests inject content within a <code><div role=none></code> into a <code><div aria-live=polite aria-atomic=false></code>.</p>
<button id=d5a>
Demo 5a (inject alternating messages)
</button>
<button id=d5b>
Demo 5b (injects the same message)
</button>
<button id=d5c>
Demo 5c (injects alternating messages without clearing out live region)
</button>
<div aria-live=polite aria-atomic=false id=d5></div>
<div class=table-container>
<table>
<caption>Demo 5a - Pass: 14, Warn: 2, Fail: 1</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes. (see group note)</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="warn">Doesn't announce 1st message, but will announce subsequent messages.</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="warn">Doesn't announce 1st message, but will announce subsequent messages.</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<div class=table-container>
<table>
<caption>Demo 5b - Pass: 14, Warn: 2, Fail: 1</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="warn">Announces first message, but not additional messages of same content.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="warn">Announces first message, but not additional messages of same content.</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
<div class=table-container>
<table>
<caption>Demo 5c - Pass: 11, Warn: 0, Fail: 6</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="no">No: announces previous content as well as new messages.</td> <!-- jaws -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="yes">Yes</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
</section>
<section>
<h2>6. Role=log aria-atomic=false</h2>
<button id="b6">Inject</button>
<div role=log id="d6" aria-atomic=false></div>
<!-- if role=status, narrator + edge will re-announce past messages.
if role=log, edge + narrator only announce the newest message. -->
<div class=table-container>
<table>
<caption>Demo 6 - Pass: 13, Warn: 2, Fail: 2</caption>
<tr>
<td></td>
<th>JAWS</th>
<th>NVDA</th>
<th>Narrator</th>
<th>VoiceOver macOS</th>
<th>VoiceOver iOS</th>
<th>TalkBack</th>
</tr>
<tr>
<th>Firefox</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="no">No announcement</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="no">No: announces previous content as well as new messages.</td> <!-- tb -->
</tr>
<tr>
<th>Chrome</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="warn">Doesn't announce 1st message, but will announce subsequent messages.</td> <!-- tb -->
</tr>
<tr>
<th>Edge</th>
<td class="yes">Yes</td> <!-- jaws -->
<td class="yes">Yes</td> <!-- nvda -->
<td class="yes">Yes</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="nt">not tested</td> <!-- VO ios -->
<td class="warn">Doesn't announce 1st message, but will announce subsequent messages.</td> <!-- tb -->
</tr>
<tr>
<th>Safari</th>
<td class="nt">n/a</td> <!-- jaws -->
<td class="nt">n/a</td> <!-- nvda -->
<td class="nt">n/a</td> <!-- narrator -->
<td class="yes">Yes</td> <!-- vo -->
<td class="yes">Yes</td> <!-- VO ios -->
<td class="nt">n/a</td> <!-- tb -->
</tr>
</table>
</div>
</section>
</div>
body {
padding: 1.5em;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
button {
margin: .5em .5em .5em 0;
}
div:empty {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0);
padding: 0.001em;
}
div > div {
box-shadow: 0 0 0 3px #666;
padding: 0.25em;
margin: 0.25em 0;
transition: box-shadow 0.2s ease-in-out, padding 0.2s ease-in-out;
}
.table-container {
max-width: 100%;
overflow: auto;
margin-bottom: 3em;
}
table {
min-width: 600px;
border-spacing: 0;
width: 100%;
caption {
text-align: left;
font-size: 1.2em;
margin-top: 1em;
font-weight: bold;
padding-bottom: .5em;
min-width: 100px;
}
td,
th {
border: 1px solid #000;
text-align: left;
padding: 0.325em;
width: 15%;
}
td:empty {
border: none;
}
}
.yes {
background: darkgreen;
color: #fff;
}
.nt {
background: #eee;
color: #555;
}
.warn {
background: lightyellow;
}
.no {
font-weight: bold;
color: darkred;
}
const doc = document;
const f = doc.getElementById("f");
const g = doc.getElementById("g");
const s = doc.getElementById("s");
const r = doc.getElementById("r");
const h = doc.getElementById("heyo");
const hbr = doc.getElementById("heyo_but_really");
const so = doc.getElementById("statuso");
const rs = doc.getElementById("rstatus");
f.addEventListener("click", function () {
h.innerHTML = "<div aria-live=polite>Hey! Listen!</div>";
});
g.addEventListener("click", function () {
hbr.innerHTML = "<div role=none>Hey! Listen!!</div>";
});
let count = 0;
s.addEventListener("click", function () {
const el = doc.createElement("p");
el.setAttribute('role', 'none');
if (count < 5) {
el.textContent = "Really! Listen!!";
} else {
el.textContent = "OK. Stop it. This is annoying.";
}
count = count + 1;
so.appendChild(el);
});
const sp2 = document.getElementById('sp2');
const sp2r = document.getElementById('sp2re');
let cSP2 = 0;
sp2.addEventListener("click", function () {
const el = doc.createElement("p");
if (cSP2 < 3) {
el.textContent = "Really! Listen!!";
} else {
el.textContent = "OK. Stop it. This is annoying.";
}
cSP2 = cSP2 + 1;
sp2r.appendChild(el);
});
r.addEventListener("click", function () {
rs.innerHTML = "";
/* this timeout was added to ensure iOS VO would announce the re-injection of the same content */
setTimeout(function () {
rs.innerHTML = "<div role=none>Hey! Listen!! D4</div>";
}, 200);
});
///
// assertives
///
const f2 = doc.getElementById("f2");
const g2 = doc.getElementById("g2");
const s2 = doc.getElementById("s2");
const r2 = doc.getElementById("r2");
const h2 = doc.getElementById("heyo2");
const hbr2 = doc.getElementById("heyo_but_really2");
const so2 = doc.getElementById("statuso2");
const rs2 = doc.getElementById("rstatus2");
f2.addEventListener("click", function () {
h2.innerHTML = "<div aria-live=assertive>Hey! Listen!</div>";
});
g2.addEventListener("click", function () {
hbr2.innerHTML = "<div role=none>Hey! Listen!!</div>";
});
let count2 = 0;
s2.addEventListener("click", function () {
const el = doc.createElement("div");
el.setAttribute('role', 'none');
if (count2 < 5) {
el.textContent = "Really! Listen!!";
} else {
el.textContent = "OK. Stop it. This is annoying.";
}
count2 = count2 + 1;
so2.appendChild(el);
});
r2.addEventListener("click", function () {
rs2.innerHTML = "";
/* thie timeout was added to enusre iOS VO would announce the re-injection of the same content */
setTimeout(function () {
rs2.innerHTML = "<div role=none>Hey! Listen!!</div>";
}, 200);
});
// demo 5
const d5 = doc.getElementById('d5');
const d5a = doc.getElementById('d5a');
const d5b = doc.getElementById('d5b');
const d5c = doc.getElementById('d5c');
let v = 0;
let a = 0;
d5a.addEventListener('click', function () {
if ( v == 0 ) {
d5.innerHTML = "<div role=none>Hey! Listen!!</div>";
v = 1;
}
else {
d5.innerHTML = "<div role=none>I'm talking to you!</div>";
v = 0;
}
});
d5b.addEventListener('click', function () {
d5.innerHTML = "";
/* this timeout was added to ensure iOS VO would announce the re-injection of the same content */
setTimeout(function () {
d5.innerHTML = "<div role=none>Hey! Listen!!</div>"; // should try with role=none
}, 200);
});
d5c.addEventListener('click', function () {
const msg1 = doc.createElement('div');
const msg2 = doc.createElement('div');
msg1.innerHTML = 'Hey! Listen!!';
msg2.textContent = "I'm talking to you!";
// adding role=none to the divs helps ensure that Chrome + Narrator will work better with this injected content. E.g., Chrome won't anounce "group" instead of the content injected
msg1.setAttribute('role', 'none');
msg2.setAttribute('role', 'none');
if ( a == 0 ) {
d5.appendChild(msg1);
a = 1;
}
else {
d5.appendChild(msg2);
a = 0;
}
});
const d6 = doc.getElementById('d6');
const b6 = doc.getElementById('b6');
let a6 = 0;
b6.addEventListener('click', function () {
const msg1 = doc.createElement('p');
const msg2 = doc.createElement('div');
msg1.innerHTML = 'Hey! Listen!!';
msg2.textContent = "I'm talking to you!";
// NOT adding role=none, as that makes JAWS announce previous messages
// rather than just the newest message.
// using <p> instead of <div> will have chrome + narrator not announce "group".
// leaving msg2 as a <div> to showcase this behavior compared to <p>
if ( a6 == 0 ) {
d6.appendChild(msg1);
a6 = 1;
}
else {
d6.appendChild(msg2);
a6 = 0;
}
});
Also see: Tab Triggers