DEV Community

Discussion on: Today I learned To Creat a FAQ Collapse

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

Great job!

Now go read about <summary> and <details> and realise it is even easier than you thought!

See if you can create the same with native HTML elements as you won’t need any JavaScript and it will be accessible for people with disabilities too (as at the moment your example isn’t).

Nice design, Keep going 💪

Collapse
 
aydoubleyou profile image
Alex Winter

OP's work is accessible. It could benefit from some visible focus styling though.

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

The button has no text that a screen reader can access, it is missing relevant aria attributes, it is positioned after the section that expands in the DOM so the read order is incorrect etc. And those are things I can spot on a phone without actually testing it.

It certainly is not accessible in its current format.

I didn’t want to list the accessibility issues as OP is doing well and I didn’t want to put them off but I thought I better point them out if you think that is an accessible pattern as I wouldn’t want you using it in production.

Hence why I suggest summary and details as you don’t need to know all of the ARIA etc

Collapse
 
w3tsa profile image
Coding Jitsu

keep in mind, details are not supported in IE, if you want to support IE, that is.

Collapse
 
grahamthedev profile image
GrahamTheDev

Yes quite right I should have said that. To be fair they do fall back quite gracefully but even so great point! ❤️

Collapse
 
kallmanation profile image
Nathan Kallman • Edited