HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
<p role=note>Oct 9, 2024: Please be aware that results have changed since original published / updated dates.</p>
<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>
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;
}
/*
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/
*/
Also see: Tab Triggers