DEV Community

Today I learned To Creat a FAQ Collapse

Ahtsham Ajus on June 26, 2021

All right, so now we want to style these buttons, these icon buttons, position them. We want to give functionality to them so we can expand and co...
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
 
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
 
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
 
kallmanation profile image
Nathan Kallman • Edited
Collapse
 
knoj profile image
knoj

This is directly from a Udemy course geared toward learning JS & CSS. It was a great course, and OP should have referenced the training.
OP presents this code as if it were their own.

Collapse
 
drsimplegraffiti profile image
Abayomi Ogunnusi

Great job....

Collapse
 
ahtshamajus profile image
Ahtsham Ajus

ThnkQ 🥰

Collapse
 
pythonvishal profile image
Vishal Chopra

Well done. A FAQ is extremely helpful for optimizing SEO content. It'll be more engaging if it has animation effects.

Collapse
 
heyprotagonist profile image
Anguram Shanmugam

Also learn to spell title right!

Collapse
 
ahtshamajus profile image
Ahtsham Ajus

Sure sir