Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<abbr />-Element: aria-label or title attribute

While it is recommended to use the title attribute on the <abbr /> element, this has no effect on screen readers (at least not on chromevox).

<abbr title="as soon as possible">ASAP</abbr>

The thing that works is of course aria-label e.g:

<abbr aria-label="as soon as possible">ASAP</abbr>

So in order to be both semantically corrent and screen reader compatible I need to mark both:

<abbr aria-label="as soon as possible" title="as soon as possible">ASAP</abbr>

which seems a bit of a hack. why doesn't chromevox just read the title attribute instead?

like image 289
loominade Avatar asked Oct 01 '15 13:10

loominade


People also ask

Should I use title or aria-label?

aria-label should be used in conjunction with the title attribute. Aria for screen readers, and title attribute for other people who want more information about the action of the button.

What is the abbr attribute?

The <abbr> tag defines an abbreviation or an acronym, like "HTML", "CSS", "Mr.", "Dr.", "ASAP", "ATM". Tip: Use the global title attribute to show the description for the abbreviation/acronym when you mouse over the element.

What is aria-label attribute?

The aria-label attribute is intended for interactive elements only. Use aria-label to ensure an accessible name is provided when none is visible in the DOM for all interactive elements, like links, videos, form controls, landmark roles, and widget roles.

What is the abbr HTML element used to represent?

The <abbr> HTML element represents an abbreviation or acronym. When including an abbreviation or acronym, provide a full expansion of the term in plain text on first use, along with the <abbr> to mark up the abbreviation. This informs the user what the abbreviation or acronym means.


1 Answers

I'm sorry to add another totally different answer but I think both answers should not be merged:

As ChromeVox is opensource, I have a second and now technical answer to your question. http://src.chromium.org/svn/trunk/src/chrome/browser/resources/chromeos/chromevox/common/dom_util.js

For any element (and there is no exception for abbreviations) ChromeVox fallbacks to the title attribute if there is no text content in the node (node.textContent.length==0)

Here is the order of precedence defined in the code:

  • Text content if it's a text node.
  • aria-labelledby
  • aria-label
  • alt (for an image)
  • title (only if there is no text content)
  • label (for a control)
  • placeholder (for an input element)
  • recursive calls to children

Now, it's kind of a buggy situation

  1. This example, in my opinion, correctly reads "BBC":

<abbr title="British Broadcasting Corporation">BBC</abbr>

  1. This one announces "British Broadcasting Corporation": which is a correct fallback to an invalid markup

<abbr title="British Broadcasting Corporation"></abbr>

  1. But this one doesn't read anything, because the node text length is not null

<abbr title="British Broadcasting Corporation"> </abbr>

If we except the last bug, it is not a perfect but quite consistent implementation of Text Alternative Computation

  • [F. Otherwise, look in the subtree]
  • G. Otherwise, if the current node is a Text node, return its textual contents.
  • H. Otherwise, if the current node has a tooltip attribute, return its value.

Note that according to the document referenced in one comment above, the title attribute, if present, should now be used by accessibility api instead of the text content: (http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#text-level-elements-not-listed-elsewhere). I'm not sure it's a good thing as the title attribute was previously and is still defined as the following by the W3.

The title attribute represents advisory information for the element, such as would be appropriate for a tooltip

like image 122
Adam Avatar answered Sep 30 '22 20:09

Adam