Today I Learned - Rocky Kev

TIL aria-expanded for showing when things are hidden/shown

POSTED ON:

TAGS:

Say you had a accordion.

aria-expanded

The aria-expanded attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not its child elements are displayed or hidden.

<style>
.topic {
display: none;
margin-bottom: 1em;
padding: .25em;
border: black thin solid;
background-color: #EEEEFF;
width: 40em;
}
</style>


<button class="buttonControl" aria-controls="topic1" aria-expanded="false">
<span>Show</span> Topic 1
</button>

<div id="topic1" class="topic" role="region" tabindex="-1" >
Topic 1 is all about being Topic 1 and may or may not have anything to do with other topics.
</div>

code via W3C wiki

via the MDN

via #99 - 101 Digital Accessibility (a11y) tips and tricks


Related TILs

Tagged:

TIL aria-expanded for showing when things are hidden/shown

The aria-expanded attribute is set on an element to indicate if a control is expanded or collapsed, and whether or not its child elements are displayed or hidden.

TIL ARIA role presentation

Think of this as a reset. You use role=presentation to remove semantic meaning from an element.

TIL reduce-motion-blur

Dizziness and vertigo are symptoms of a vestibular balance disorder. If the user has set up a user preference that they prefer motion-based animation be disabled/reduced, we can tap into that. As web developers, we can also support them.