Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <header>
  <h1>
    <code>summary</code> with heading and role=button tests
  </h1>
  <p>Published: September 2, 2018</p>
  <p>Updated: June 16, 2022</p>
</header>


<main>
  <aside>
    <p>See also:
      <a href="https://codepen.io/scottohara/pen/vYWvWEY?editors=1000">styled summary test case</a>
    </p>
    <p>
      <a href="https://codepen.io/scottohara/pen/ExogpRN">naming a details element test case</a>
    </p>
    <p>And, <a href="https://codepen.io/scottohara/pen/VwrqrOm">giving details a different role results</a></p>
  </aside>
  <div class=tests>
    
    <h2>0. Control - details/summary with no headings or roles</h2>
    <details>
      <summary>
        Trigger 0
      </summary>
      My content
    </details>

    <h2>1. With heading test</h2>
    <details>
      <summary>
        <h3>Trigger 1</h3>
      </summary>
      My content
    </details>

    <h2>2. No heading and <code>summary[role="button"]</code></h2>
    <details>
      <summary role="button">
        Trigger 2
      </summary>
      My content
    </details>


    <h2>3. With heading and <code>summary[role="button"]</code></h2>
    <details>
      <summary role="button">
        <h3>Trigger 3</h3>
      </summary>
      My content
    </details>
  </div>
  <div class=results>
    
    <div class=result-tables>
 <table>
  <caption>test 0: control</caption>
  <tr>
    <td></td>
    <th>Narrator + Edge</th>

    <th>macOS VoiceOver + Edge/Chrome</th>
    <th>macOS VoiceOver + Firefox</th>
    <th>macOS VoiceOver + Safari</th>

    <th>iOS VoiceOver + Safari</th>

    <th>NVDA + Edge/Chrome</th>
    <th>NVDA + Firefox</th>

    <th>JAWS + Edge/Chrome</th>
    <th>JAWS + Firefox</th>

    <th>TalkBack + Edge/Chrome</th>
    <th>TalkBack + Firefox</th>
  </tr>

  <tr>
    <th>Summary role announced?</th>
    <!-- narrator -->
    <td>"Disclosure Triangle"</td>
    
    <!-- mosvo -->
    <td>"Disclosure Triangle"</td>
    <td>"Summary"</td>
    <td>"Summary"</td>
    
    <td class="concern">No role exposed</td>
    
    <!-- nvda -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- jaws -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- tb -->
    <td>"Disclosure triangle"</td>
    <td class="concern">On initial focus, no. After toggle, yes "Button". On re-navigation to control, no. Disclosure triangle focused w/no role. 'trigger' text focused with no role.</td>
  </tr>


  <tr>
    <th>Expand/Collapse state exposed?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">On initial focus, Yes. <br>On toggle, No. Instead direction of "triangle" is announced (accName update).</td>
    <td>Yes</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td class="concern">On initial focus, no.  After toggle, yes. On re-navigation to control disclosure triangle and 'trigger' text separately focusable with no state annoumcent. On toggle, collapsed/expanded announced.</td>
  </tr>


  <tr>
    <th>Trigger discoverable by button/form control nav?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">No</td>
    <td class="concern">No</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td class="concern">No</td>
  </tr>

  <tr>
    <th>details element exposed?</th>
    <!-- narrator -->
    <td>No</td>
    
    <!-- mosvo -->
    <td>No. See 'group announcement note'</td>
    <td>No. See 'group announcement note'</td>
    <td>No. See 'group announcement note'</td>
    
    <td>No</td>
    
    <!-- nvda -->
    <td>No</td>
    <td>No</td>
    
    <!-- jaws -->
    <td>No</td>
    <td>No</td>
    
    <!-- tb -->
    <td>No</td>
    <td>No</td>
  </tr>
</table>

<table>
  <caption>test 1</caption>
  <tr>
    <td></td>
    <th>Narrator + Edge</th>

    <th>macOS VoiceOver + Edge/Chrome</th>
    <th>macOS VoiceOver + Firefox</th>
    <th>macOS VoiceOver + Safari</th>

    <th>iOS VoiceOver + Safari</th>

    <th>NVDA + Edge/Chrome</th>
    <th>NVDA + Firefox</th>

    <th>JAWS + Edge/Chrome</th>
    <th>JAWS + Firefox</th>

    <th>TalkBack + Edge/Chrome</th>
    <th>TalkBack + Firefox</th>
  </tr>

  <tr>
    <th>Summary role announced?</th>
    <!-- narrator -->
    <td>"Disclosure Triangle"</td>
    
    <!-- mosvo -->
    <td>"Disclosure Triangle"</td>
    <td>"Summary"</td>
    <td>"Summary"</td>
    
    <td class="concern">No role exposed</td>
    
    <!-- nvda -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- jaws -->
    <td>"Button"</td>
    <td>"Button:</td>
    
    <!-- tb -->
    <td>"Button"</td>
    <td class="concern">On initial load, only 'heading' announced.  Double tapping disclosure triangle itself becomes focusable w/out role announcement.</td>
  </tr>


  <tr>
    <th>Heading exposed?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td>Yes</td>
    <td>Yes</td>
    
    <td>Yes</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td class="concern">No</td>
    <td class="concern">No</td>
    
    <!-- tb -->
    <td class="concern">No</td>
    <td>Yes</td>
  </tr>

  <tr>
    <th>Expand/Collapse state exposed?</th>
    <!-- narrator -->
    <td>Yes (also announced 'disclosure triangle')</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">On initial focus: Yes<br>On toggle: No (announces change in triangle direction instead)</td>
    <td>Yes</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td class="concern">On initial focus: No<br>On toggle: Yes</td>
  </tr>


  <tr>
    <th>Trigger discoverable by button/form control nav?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">No</td>
    <td>Yes</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td class="concern">No</td>
  </tr>

  <tr>
    <th>details element exposed?</th>
    <!-- narrator -->
    <td>No</td>
    
    <!-- mosvo -->
    <td>No. See 'group announcement note'</td>
    <td>No. See 'group announcement note'</td>
    <td>No. See 'group announcement note'</td>
    
    <td>No</td>
    
    <!-- nvda -->
    <td>No</td>
    <td>No</td>
    
    <!-- jaws -->
    <td>No</td>
    <td>No</td>
    
    <!-- tb -->
    <td>No</td>
    <td>No</td>
  </tr>
</table>

<table>
  <caption>test 2</caption>
  <tr>
    <td></td>
    <th>Narrator + Edge</th>

    <th>macOS VoiceOver + Edge/Chrome</th>
    <th>macOS VoiceOver + Firefox</th>
    <th>macOS VoiceOver + Safari</th>

    <th>iOS VoiceOver + Safari</th>

    <th>NVDA + Edge/Chrome</th>
    <th>NVDA + Firefox</th>

    <th>JAWS + Edge/Chrome</th>
    <th>JAWS + Firefox</th>

    <th>TalkBack + Edge/Chrome</th>
    <th>TalkBack + Firefox</th>
  </tr>

  <tr>
    <th>Summary role announced?</th>
    <!-- narrator -->
    <td>"Button"</td>
    
    <!-- mosvo -->
    <td>"Button"</td>
    <td>"Button"</td>
    <td>"Button"</td>
    
    <td>"Button"</td>
    
    <!-- nvda -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- jaws -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- tb -->
    <td>"Button"</td>
    <td>"Button"</td>
  </tr>

  <tr>
    <th>Expand/Collapse state exposed?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">On initial focus: Yes<br>On toggle: No (announces change in triangle direction instead)</td>
    <td class="concern">No</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td>Yes</td>
  </tr>


  <tr>
    <th>Trigger discoverable by button/form control nav?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td>Yes</td>
    <td>Yes</td>
    
    <td>Yes</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td>Yes</td>
  </tr>

  <tr>
    <th>details element exposed?</th>
    <!-- narrator -->
    <td>No</td>
    
    <!-- mosvo -->
    <td>No</td>
    <td>No</td>
    <td>No</td>
    
    <td>No</td>
    
    <!-- nvda -->
    <td>No</td>
    <td>No</td>
    
    <!-- jaws -->
    <td>No</td>
    <td>No</td>
    
    <!-- tb -->
    <td>No</td>
    <td>No</td>
  </tr>
</table>

<table>
  <caption>test 3</caption>
  <tr>
    <td></td>
    <th>Narrator + Edge</th>

    <th>macOS VoiceOver + Edge/Chrome</th>
    <th>macOS VoiceOver + Firefox</th>
    <th>macOS VoiceOver + Safari</th>

    <th>iOS VoiceOver + Safari</th>

    <th>NVDA + Edge/Chrome</th>
    <th>NVDA + Firefox</th>

    <th>JAWS + Edge/Chrome</th>
    <th>JAWS + Firefox</th>

    <th>TalkBack + Edge/Chrome</th>
    <th>TalkBack + Firefox</th>
  </tr>


  <tr>
    <th>Summary role announced?</th>
    <!-- narrator -->
    <td>"Button"</td>
    
    <!-- mosvo -->
    <td>"Button"</td>
    <td>"Button"</td>
    <td>"Button"</td>
    
    <td>"Button"</td>
    
    <!-- nvda -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- jaws -->
    <td>"Button"</td>
    <td>"Button"</td>
    
    <!-- tb -->
    <td>"Button"</td>
    <td>"Button"</td>
  </tr>


  <tr>
    <th>Heading exposed?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td>Yes</td>
    <td class="concern">No</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td class="concern">No</td>
    <td class="concern">No</td>
    
    <!-- tb -->
    <td class="concern">No</td>
    <td class="concern">Yes (but only when navigating by headings. basic left/right swiping did not announce heading role)</td>
  </tr>

  <tr>
    <th>Expand/Collapse state exposed?</th>
    <!-- narrator -->
    <td>Yes (does not announce 'disclosure triangle')</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td class="concern">On initial focus: Yes<br>On toggle: No (announces change in triangle direction instead)</td>
    <td class="concern">No</td>
    
    <td class="concern">No</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td>Yes</td>
  </tr>

  <tr>
    <th>Trigger discoverable by button/form control nav?</th>
    <!-- narrator -->
    <td>Yes</td>
    
    <!-- mosvo -->
    <td>Yes</td>
    <td>Yes</td>
    <td>Yes</td>
    
    <td>Yes</td>
    
    <!-- nvda -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- jaws -->
    <td>Yes</td>
    <td>Yes</td>
    
    <!-- tb -->
    <td>Yes</td>
    <td>Yes</td>
  </tr>

  <tr>
    <th>details element exposed?</th>
    <!-- narrator -->
    <td>No</td>
    
    <!-- mosvo -->
    <td>No. See 'group announcement note'</td>
    <td>No. See 'group announcement note'</td>
    <td>No</td>
    
    <td>No</td>
    
    <!-- nvda -->
    <td>No</td>
    <td>No</td>
    
    <!-- jaws -->
    <td>No</td>
    <td>No</td>
    
    <!-- tb -->
    <td>No</td>
    <td>No</td>
  </tr>
</table>


    </div>


<div role=note aria-labelledby=ga>
<h3 id=ga>group announcement</h3>
<p>
  With macOS VO and some tests a "group" role announcement can be heard when initially navigating to the disclosure widget trigger.  This announcement is not for the 'details' element, but rather is part of the summary's announcement. It's a bit odd.  
</p>
<p>When expanding the disclosure widget, the exposed content is not contained within the 'group' - hence the role announcement not seeming to represent the container details element.</p>
</div>
    
    <div role=note aria-labelledby=ec>
      <h3 id=ec>headings in buttons</h3>
      <p>With most instances of screen reader/browser pairings where a heading is discoverable, if one has navigated directly to the heading (e.g., by use of the <kbd>H</kbd> key with NVDA), toggling the disclosure widget may not be possible. This is because the screen reader is virtually 'focused' on the heading element, rather than the summary which is the actual toggle control.  In these instances, one MUST navigate to the parent summary to effectively toggle the disclosure widget.
      </p>
      <p>In other cases, such as with macOS + VO - using standard VO navigation (VO key + <kbd>right</kbd> arrow, for instance) the heading may not be discovered. However, if navigating specifically by headings it would be. Or, if one attempted to navigate <strong>into the summary</strong> (VO key + <kbd>down</kbd> arrow), then one could hear the heading role if one was available.</p>
    </div>



    <h3>General testing info</h3>
    <p>
      Results from latest browsers / screen readers at time of last update.  Tested on Win11, macOS 12.4, iOS 15.5, Android 12
    </p>
  </div>
</main>
              
            
!

CSS

              
                body {
  font-family: arial;
  margin: 1.25em;
  background: #fafafa;
  padding: .55em;
}

header {
  margin: 0 0 .75em;
  padding-bottom: .75em;
  border-bottom: 1px solid #aaa;
  
  h1 {
    margin: 0;
  }
  
  :last-child {
    margin-bottom: 0;
  }
}

summary h3 {
  display: inline-block;
  margin: 0;
}

h2 {
  margin-top: 1.5em;
  margin-bottom: .75em;
}

.tests {
  max-width: 400px;
}

caption { text-align: left; font-size: 1.25em; margin-top: 1em;}

.results {
  
  table {
    width: 100%;
    min-width: 1100px;
    
  }
  th {
    word-break: break-word;
    font-size: .82em;
  }
  th, td:not(:empty) {
    border: 1px solid;
    text-align: left;
    padding: .25em;
    min-width: 140px;
  }
}

.result-tables {
  overflow: auto;
}

li p {
  margin: .5em 0;
}

.concern {
  background: lightyellow;
  font-weight: bold;
}

              
            
!

JS

              
                /*
other instances of test pages of past results which may or may not be different than the results recorded on this page.

summary element role announcements:
https://codepen.io/scottohara/pen/RwZVmOq

results for specifying role=button on a summary element:
https://codepen.io/scottohara/pen/bGaBoBg

other older test cases for details/summary 
https://scottaohara.github.io/tests/html-details-summary/mixed-content.html

https://scottaohara.github.io/tests/html-details-summary/
*/
              
            
!
999px

Console