FAQ Acccordion Card - Using HTML, CSSS and JS

Solution retrospective
Would like some feedback on the code, areas where I could improve my code.
Is it possible to make the accordion without JS?
Thanks!
Please log in to post a comment
Log in with GitHubCommunity feedback
- @osoriodev
Hello Vinicius.
You have an img tag without the src attribute, it is always necessary to set this attribute and the alt attribute, for accessibility.
And yes, it is possible to do the accordion without JS, but you have to use some tricks with CSS. Using checkbox inputs (or radio inputs if you want only one question to be displayed at a time), the checked pseudo-class and the general sibling operator: ~ . With this you have the basic logic to make the accordion.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord