Short note on hiding stuff in interactive elements from screen readers

Posted on Monday, 19 February 2018 by Steve Faulkner

Text symbols on buttons.

Symbols are cool. They add decoration and/or information to user interfaces. For screen reader users their inclusion can sometimes be annoying or confusing as the visual and aural user interface differ.

The term symbol in this case refers to UTF-8 symbols and related text characters used as symbols or icons.

If symbols are included as a child of an interactive element such as a <button> or <a href…> their content will be used as part of the accessible name calculation for the interactive element. Why? because they are exposed in the HTML DOM, as text in modern browsers, even when they are included as CSS “content” , and text children of such elements are concatenated and used as the accessible name for the element, by browsers, regardless of their state (hidden or not), thus may be spoken by screen reader software.

Update 20/2/2018

The cause of the announcement is not as I previously stated, it is due to  how Firefox have implemented support for aria-hidden, which results in hidden content being included in the accessible name

Given the following:

<button><span aria-hidden="true">poot</span> Pat</button>

Firefox exposes the label of the button as “poot Pat”. The aria-hidden text is present in the accessibility tree, but has an iA2 object attribute property of hidden=true

Chrome meanwhile, exposes the label of the button as “Pat” and does not include the hidden content in the accessibility tree.

there 2 Firefox bugs related to this behavior:

  1. aria-hidden state not honoured with CSS generated content
  2. exclude aria-hidden=”true” elements from the tree

Thanks to Patrick Lauke and others for questioning the initial results and conclusions.

The use of child text elements as part of the accessible name calculation in Firefox can be overridden by placing source for the accessible name on the button element itself:

See the Pen Hiding symbols from screen readers by steve faulkner (@stevef) on CodePen.


In the process of testing this issue I found that the announcement of UTF-8 symbols by screen readers is all over the place. If you do want them to be announced, try:

<span role="img" aria-label="Peace">☮</span>

Further reading

About Steve Faulkner

Steve is the Technical Director at TPG. He joined The Paciello Group in 2006 and was previously a Senior Web Accessibility Consultant at vision australia. He is the creator and lead developer of the Web Accessibility Toolbar accessibility testing tool. Steve is a member of several groups, including the W3C Web Platforms Working Group and the W3C ARIA Working Group. He is an editor of several specifications at the W3C including HTML 5.1, ARIA in HTML, Notes on Using ARIA in HTML and HTML5: Techniques for providing useful text alternatives. He also develops and maintains HTML5accessibility.


Comments for this post are closed.