Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DIV ARIA-LABEl not being read by JAWS

I have an angular2 application and I am binding some dynamic text to ARIA-LABEl for a nested DIV. But when I use the JAWS reader to locate DIVs on the page , it is not reading the assigned text.This is the text I am trying to read - attr.aria-label="Product details for {{productDetails?.ProductName}}"

Also if I give assign a role of heading to this div, it reads the dynamic text but doesn't prefix "Product details for " before the text

<div [ngClass]="getDescClass()" class="prdDetails-div" aria-label="some text">
<div autofocus attr.aria-label="Product details for {{productDetails?.ProductName}}" class="productDetails-name" style="cursor:default!important" role="heading" >{{productDetails?.ProductName}}   </div>
        <div autofocus class="products-result-compare">
            <!--{{getDescription(productDetails?.Description)}}-->
            Small description
        </div>
like image 308
namrata Avatar asked Mar 08 '17 20:03

namrata


People also ask

Does Jaws read aria-label?

JAWS ignores the aria-label or aria-labelledby . If the role is a static role then aria-label will be ignored by all screen readers except Talkback which overrides the static content (except if its listitem role, then its ignored).

Are aria LABELs read by screen readers?

The purpose of this technique is to provide a label for objects that can be read by assistive technology. The aria-label attribute provides the text label for an object, such as a button. When a screen reader encounters the object, the aria-label text is read so that the user will know what it is.

How do I know if my aria-label is working?

You can turn on NVDA's speech viewer tool (ins+n > tools > speech viewer) and you can see what is being spoken. VoiceOver has a "closed captions" type viewer so you can see what's being announced. Your aria-labels will be read by the screen reader.

Can we use aria-label for P tag?

Don't use aria-label or aria-labelledby on any other non-interactive content such as p , legend , li , or ul , because it is ignored. As an aside, it's a little unusual to have paragraph text read differently than what is visually displayed.


1 Answers

Your description lacks detail or a working example, so instead of trying to offer a solution all I can offer is this: aria-label does not work on <div> nor <span>.

A <div> and <span> are neither landmarks nor interactive content. An aria-label will not be read by a screen reader (and rightly so).

Without knowing the use, I have two suggestions which might help:

  1. Put the aria-label directly on the control (knowing it will override the text of the control).

  2. Use some off-screen text if you want it to be encountered only by screen reader users.

Use an off-screen technique:

<div class="sr-only">
Here be redundant or extraneous content
</div>

The CSS might look like this (accounting for RTL languages too):

.SRonly {
  position: absolute !important;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
  top: auto;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

html[dir=rtl] .SRonly {
  left: inherit;
  left: unset;
  right: -9999px;
}

There are other techniques, but their value depends on your audience and its technology profile.

Your use of autofocus on those <div> makes me nervous. I hope you are not using them as interactive controls (like buttons). Ideally never use a div as interactive content.

like image 140
aardrian Avatar answered Sep 29 '22 00:09

aardrian