Design comparison
Solution retrospective
Hi guys and girls! I did another task, but I have one question about improving this project. All I wanted to ask is about the transition of answers to the questions in FAQ. I had a problem with doing that, I didn't know how to do it, where to put properties, etc.
Thank you in advance for your response! :)
Community feedback
- @petritnurediniPosted 10 months ago
Great job on completing the Frontend Mentor challenge for the FAQ accordion! Your project showcases a good understanding of HTML, CSS, and JavaScript. Here are a few suggestions to further refine your code:
-
Improve Accessibility and Semantic HTML:
- Use
<button>
elements for interactive elements like the FAQ toggles instead of<img>
. This enhances accessibility as buttons are more semantically appropriate for interactive elements. - Example:
<button class="toggle-btn" aria-expanded="false"> <img src="assets/icon-plus.svg" alt="Expand"> </button>
- Use
-
Avoid Redundant IDs and Inline Event Handlers:
- Instead of using multiple IDs and inline event handlers, consider using classes and adding event listeners in your JavaScript. This approach reduces redundancy and makes your code cleaner.
- Example:
document.querySelectorAll('.question').forEach(question => { question.addEventListener('click', toggleFAQ); }); function toggleFAQ(event) { // Toggle logic here }
-
CSS Optimization:
- Consolidate your media queries and CSS files. Having separate files for media queries (
media-query.css
) isn't necessary and can be combined into your main stylesheet for better organization. - Utilize CSS variables for repeated values like colors, fonts, etc., to make your stylesheet easier to maintain.
- Consolidate your media queries and CSS files. Having separate files for media queries (
Additional Resources:
- For accessibility best practices, visit Web Accessibility Initiative (WAI).
- Check out MDN Web Docs on CSS Variables for more on CSS custom properties.
Keep pushing the boundaries of your coding skills, and don't hesitate to explore new challenges. Each project you build is a stepping stone to becoming a proficient developer! 🚀💻
Marked as helpful2@tloxiuPosted 10 months ago@petritnuredini Thanks for your suggestion. I will keep that in mind! :)
0 -
- @RazaAbbas62Posted 10 months ago
Hi, @tloxiu in your
question p
in CSS you can usetransition: height 0.3s linear;
it would make a smooth transition between hiding and showing your answer
I hope it would help
Enjoy coding :)
Marked as helpful1
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