Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

FAQ-Accordion

jmoody28 20

@jmoody28

Desktop design screenshot for the FAQ accordion coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm most proud of recognizing that i was writing too much javascript code when I first started and thinking of ways to cut out or simplify unnecessary code.

What challenges did you encounter, and how did you overcome them?

I had trouble figuring out how to open and collapse the accordion. My first attempt was to have a function that would append and remove a element on button click but could not get it to work like I thought it would. Eventually I did some reading on MDN and figured I could make a function that would just change the display property of the text.

What specific areas of your project would you like help with?

I don't have anything in particular I want feedback on but any advice or criticism will be appreciated.

Community feedback

@Aggressive-Mohammed

Posted

Your FAQ accordion code is nicely structured and readable. However, I have a few suggestions to help improve it in terms of best practices, accessibility, and maintainability:

  1. Semantic HTML Use <details> and <summary>: Instead of using buttons for your accordion, you can use the <details> and <summary> elements, which are semantic for this type of content and automatically include accessible features like keyboard navigation.
<details> <summary>What is Frontend Mentor, and how will it help me?</summary> <p> Frontend Mentor offers realistic coding challenges to help developers improve their frontend coding skills... </p> </details> This not only makes your code more semantic but also provides out-of-the-box accessibility for screen readers.
  1. Accessibility Keyboard Accessibility: If you stick with buttons, make sure the accordion is accessible via keyboard. Adding aria-expanded attributes on the buttons can help screen readers understand whether a section is expanded or collapsed.
<button class="drop-down" aria-expanded="false" aria-controls="faq1"> What is Frontend Mentor, and how will it help me? </button> <div class="info" id="faq1" hidden> <p>Frontend Mentor offers realistic coding challenges...</p> </div> You’ll also want to toggle the aria-expanded attribute and show/hide the content dynamically with JavaScript when a button is clicked.
  1. Improve SEO Meta Description: Consider adding a meta description for better SEO and to improve the way your page looks when shared on social media.
<meta name="description" content="Frequently asked questions about Frontend Mentor and how it helps developers improve their frontend coding skills." />
  1. Performance Optimization Preload Critical Resources: You can optimize font loading by preloading the Google Fonts stylesheet, as font loading can sometimes block rendering.
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap" as="style">
  1. Fallback for Older Browsers If you're using newer CSS or JavaScript features, ensure you test your code on different browsers or provide fallbacks where necessary.

Final Thoughts Overall, your structure is great, but integrating semantic elements, accessibility, and performance best practices can make your FAQ accordion component even more robust and user-friendly!

0

Please log in to post a comment

Log in with GitHub
Discord logo

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