Skip to content

Instantly share code, notes, and snippets.

@fuzzbomb
Last active August 13, 2018 17:08
Show Gist options
  • Save fuzzbomb/46c17ff361ce25bc0610b027b03f67bc to your computer and use it in GitHub Desktop.
Save fuzzbomb/46c17ff361ce25bc0610b027b03f67bc to your computer and use it in GitHub Desktop.
Using aria-label to override content of a HTML heading
<h1 aria-label="big blue banana">Big<span>yellow</span>bananas</h1>
<p>
This is a test of whether an <code>aria-label</code> will work on a heading element. The use-case is for a heading which has several words, but contains no spaces. The <code>aria-label</code> is intended to provide a properly-spaced alternative to the heading content, to avoid mispronunciation problems by screen readers.
</p>
<p>This is an experiment, to answer a StackOverflow question. See <a href="https://stackoverflow.com/questions/51816452/how-do-screen-readers-handle-text-separated-by-tags-not-spaces">How do screen readers handle text separated by tags (not spaces)?</a></p>
<p>TODO: Test in various screen readers, note results here. Does the screen reader say yellow, or blue?</p>
h1 span {
font-weight: 100;
color: yellow;
}

Using aria-label to override content of a HTML heading

A test of whether aria-label can be used to override a HTML heading. The use case is a heading with several words but no spaces between them. The aria-label is intended to provide the same heading, but with spaces between words, to make pronunciation more robust.

A Pen by Andrew Macpherson on CodePen.

License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment