Submitted about 1 month ago
Faq accordion page using HTML, CSS and JavaScript
@Michael-mikeojj
Design comparison
SolutionDesign
Solution retrospective
What are you most proud of, and what would you do differently next time?
I'm proud of finally completing my first project with JavaScript.
What challenges did you encounter, and how did you overcome them?Nothing quite extraordinary
What specific areas of your project would you like help with?Adding keyboard functionality for page navigation
Community feedback
- @AdalbertPunguPosted 9 days ago
Semantic HTML
- Consider using
<section>
tags for each FAQ block instead of<div>
to more clearly indicate the distinct sections of the page. - Wrap each question in a
<h2>
or<h3>
tag instead of<p class="question">
, which improves semantic structure and helps screen readers identify key content sections. - Using
<button>
for the toggle is good, but each button should ideally includearia-expanded="false"
andaria-controls="answer-id"
to improve accessibility.
Accessibility
- Each FAQ toggle button lacks an accessible label. You could add
aria-label
attributes to the buttons, or usearia-expanded
to communicate the open/close state to screen readers. - Consider using more descriptive
alt
text for the background and icon images. Instead of “background pattern” or “star,” give more context for what these images represent or how they fit into the design.
Code Structure, Readability, and Reusability
- It could benefit from using CSS variables for colors, as this would improve maintainability and make it easy to adapt the theme if needed.
- You could simplify the JavaScript by creating a reusable toggle function rather than repeating innerHTML code for each toggle.
Marked as helpful0 - Consider using
Please log in to post a comment
Log in with GitHubJoin 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