A11y masters....help
I have an accordion element
is this the correct way to use aria-controls and aria-expanded? And then in javascript, just toggle the aria-expanded attr? The article i read said when aria-controls is set and aria-expanded="false" there will be a hidden attribute on the element it controls but im not seeing that in dev tools on #accordion-content-1
While i have you, what is the correct aria attr for close buttons? Would it be an aria controls for the parent element?
3 Replies
Looks like Iām missing a couple roles and an aria-labelledby which I though should be a aria-controlledby on the element that is hidden.
I thought I read that if the button has the right attributes , it will add hidden on the element it controls (in this case #accordion-content-1) automatically whenever aria-expanded changes
https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
Web Accessibility Initiative (WAI)
Accordion Pattern (Sections With Show/Hide Functionality)
Accessibility resources free online from the international standards organization: W3C Web Accessibility Initiative (WAI).
I was gonna link that page because I've used that in the past, and looking at the example it says not to use it in prod which I conveniently didn't see before š
Uh oh
Great