I am trying to get my screen reader to read the message whenever my page loads with a message. Below is the code that I have used. I could read the message when I hover on the text. But, for some reason I cannot get the screen reader to read my message on page load . Please suggest if there is something that I need to do.
<div class="bannerError">
<div class="bannerError_image"></div>
<span class="bannerError_text" aria-live="assertive">Please enter your name
</span>
</div>
I am trying to get my screen reader to read the message whenever my page loads with a message. Below is the code that I have used. I could read the message when I hover on the text. But, for some reason I cannot get the screen reader to read my message on page load . Please suggest if there is something that I need to do.
<div class="bannerError">
<div class="bannerError_image"></div>
<span class="bannerError_text" aria-live="assertive">Please enter your name
</span>
</div>
Share
Improve this question
edited Feb 23, 2018 at 16:46
James Z
12.3k10 gold badges27 silver badges47 bronze badges
asked Feb 23, 2018 at 13:35
AravindAravind
792 gold badges2 silver badges12 bronze badges
1 Answer
Reset to default 5The live region container must be present in the HTML at the time of page load, however it should not contain any content initially.
Only after the page has loaded will the contents of the live region be monitored for updates. Adding content to the live region is typically acplished via JavaScript.
You may want to take a look at the WCAG page for aria-live usage: W3C - Using ARIA role=alert or Live Regions to Identify Errors
Also, Terril Thompson has a pretty good live region testing page that illustrates some of the different ways that aria-live can be implemented.