Skip to content

Instantly share code, notes, and snippets.

@lemnis
Last active September 5, 2017 18:29
Show Gist options
  • Save lemnis/f5ef0d7bb5a01349d4c2320e615df34b to your computer and use it in GitHub Desktop.
Save lemnis/f5ef0d7bb5a01349d4c2320e615df34b to your computer and use it in GitHub Desktop.
Personal reference for accessible markup

Toggle button

<button type="button" aria-pressed="false">Test</button>
<div role="button" aria-pressed="false" tabindex="0">Test</div>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, toggle button Test, button Test, toggle button Test, button not pressed
Title / Name Test Test Test Test
Label
Type / Role toggle button button toggle button button
Value / Pressed 0 0 false
API Role: AXCheckbox
Subrole: AXToggle
Role: AXButton Role: AXCheckbox
Subrole: AXToggleButton
<button type="button" aria-pressed="true">Test</button>
<div role="button" aria-pressed="true" tabindex="0">Test</div>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, selected, toggle button Test, button Test, selected, toggle button Test, button pressed
Title / Name Test Test Test Test
Label
Type / Role toggle button button toggle button button
Value / Pressed 1 1 true
API Role: AXCheckbox
Subrole: AXToggle
Role: AXButton Role: AXCheckbox
Subrole: AXToggleButton

<details> and <summary>

<details><summary>Test</summary>content</details>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, collapsed, summary Test Test, collapsed, disclosure triangle Test (next) content
Title / Name Test Test Test Test
Label
Type / Role summary group discolusre triangle DisclosureTriangle
API Role: AXButton
Subrole: AXSummary
Expanded: false
Role: AXButton
Subrole: AXSummary
Role: AXButton Expanded: false
<details open><summary>Test</summary>content</details>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, expanded, summary (next) content Test (next) content Test, expanded, disclosure triangle (next) content Test (next) content
Title / Name Test Test Test Test (next) content
Label
Type / Role summary group disclosure triangle DisclosureTriangle
API Role: AXButton
Subrole: AXSummary
Expanded: true
Role: AXButton
Subrole: AXSummary
Role: AXButton Expanded: true
<details open>content</details>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Details, expanded, summary content (next) details Details, disclosure triangle (next) content Content
Title / Name Details Details
Label
Type / Role summary group disclosure triangle Details
API Role: AXButton
Subrole: AXSummary
Expanded: true
Role: AXButton
Subrole: AXSummary
Role: AXButton

Visibility

Is shown / pronounced? 1st = screen, 2nd = screen reader

Code Safari 10 Firefox 55 Chrome 62
<div hidden> Test </div> ✗ ✗ ✗ ✗ ✗ ✗
<div style=" display:none; "> Test </div> ✗ ✗ ✗ ✗ ✗ ✗
<div style=" visibility:hidden; "> Test </div> ✗ ✗ ✗ ✗ ✗ ✗
<div aria-hidden="true"> Test </div> ✓ ✗ ✓ ✓ ✓ ✗
<div style="width:0; height: 0; overflow:hidden;"> Test </div> ✗ ✓ ✗ ✓ ✗ ✓
<div style=" text-indent:-1000px; "> Test </div> ✗ ✓ ✗ ✓ ✗ ✓
<div style=" clip: rect(1px, 1px, 1px, 1px); position: absolute;"> Test </div> ✗ ✓ ✗ ✓ ✗ ✓
<div style=" position: absolute; left: -999px"> Test </div> ✗ ✓ ✗ ✓ ✗ ✓
Code AX type & chrome.automation role VoiceOver ChromeVox
<nav> navigation navigation 1 item navigation
<ul role="menu"> menu menu 2 items menu with 2 items
<li role="presentation">
<a role="menuitem" href="#">Home</a> menu item home, menu item 1 of 2 home, menu item 1 of 2

<svg>

ref: https://www.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/

<svg role="img"><title>Test</title>...</svg>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test group Test, image Test, image image
Title / Name Test Test Test Test
Label
Type / Role group image image img
Value / Pressed
API Role: AXGroup Role: AXImage Role: AXImage Labeled by: title
<svg role="img" aria-label="Test">...</svg>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test group Test, image Test, image Test, image
Title / Name Test Test
Label Test Test
Type / Role group image image img
Value / Pressed
API Role: AXGroup Role: AXImage Role: AXImage aria-label: "Test"

Note: ChromeVox currently doesn't pronounce <title> or aria-labelby while it's visible witin the automation API

<svg role="presentation"><g role="img" aria-label="Test">...</g></svg>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, image Test, image Test, image Test, image
Title / Name Test Test
Label Test Test
Type / Role image image image img
Value / Pressed
API Role: AXImage Role: AXImage Role: AXImage aria-label: "Test"

Note: Adds Safari support, but the SVG can't have title element as direct child

Symbol's

<svg role="presentation">
  <use role="img" xlink:href="#r" />
</svg>
<svg>
  <symbol id="r">
    <title>Test</title>
    ...
  </symbol>
</svg>
Safari 10 + VoiceOver Firefox 55 + VoiceOver Chrome 62 + VoiceOver Chrome 62 + ChromeVox 53
Spoken output Test, image image image image
Title / Name
Label Test
Type / Role image image image img
Value / Pressed
API Role: AXImage Role: AXImage Role: AXImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment