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

Responsive FAQs accordion with the help of display flex, position.

@Priyanshu-WD

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


Hi, I got to know the idea to use for Each in real projects. This project taught me a lot. The technologies I used were HTML, CSS, and JavaScript.

I gave my best to this project. Please help me to improve my code.

Thanks

Community feedback

T
Grace 29,310

@grace-snow

Posted

I hope this is helpful

  1. Use the picture element for serving responsive images not hiding/showing different ones with css. The picture element is far more performant, only downloading the relevant image for the users screen size, not both of them like with the css method.
  2. Decorative images must have empty alt. There's a good post in the resources channel on discord about how and when to write alt text.
  3. The section element is not appropriate here. All of this content should be within a main landmark.
  4. This is currently completely inaccessible because of your html (and js). It needs more than just buttons. Read my tutorial. It is essential to consider your html carefully.
  5. It's better for performance to link fonts in the html head instead of css imports.
  6. Always use a modern css reset at the start of the styles in every project. Look up Andy Bell's one and get into the habit of using a full one.
  7. Don't style on IDs. That's not what they are for and it increases css specificity drastically (never a good thing)
  8. The component max width should be in rem not px.
  9. Use flex or grid properties to center a component in the viewport not position absolute. Personally I wouod use css grid for this whole page layout.
  10. Do not use floats! You will almost never need them in modern development. The only time may be in prose content like a blog if you want text to flow around images.
  11. Mobile styles should be the default.
  12. Do not write media queries like this. They must be defined in rem or em not px. And if working desktop first you will only need max-width not a max and min width in combination. When working mobile first you will only need a min width media query. See fedmentor.dev/posts/responsive-meaning

Marked as helpful

0

@Priyanshu-WD

Posted

Hey, @grace-snow, thank you so much, I get to know a lot. As a self-taught developer, it's really helpful for me.

0

@petritnuredini

Posted

Congratulations on completing your FAQ Accordion project! 🌟 Your project shows a great understanding of HTML, CSS, and JavaScript, creating a functional and visually appealing FAQ section. Here are some suggestions to further improve your project:

  1. HTML Best Practices:

    • Semantic HTML: Use semantic HTML tags where possible. For example, consider using <button> instead of <div> for interactive elements.
    • Alt Text: Good job using alt text for images! Ensure it's descriptive for better accessibility.
  2. CSS Styling:

    • Consistent Naming Convention: Use a consistent naming convention for your CSS classes to improve readability and maintainability.
    • Responsive Design: Test your design on various screen sizes. Consider using relative units like em or rem instead of px for better scalability.
  3. JavaScript Enhancements:

    • Code Refactoring: The JavaScript code can be refactored to make it more concise. For example, you can toggle a class to show/hide the accordion content instead of directly manipulating styles.
    • Event Delegation: Use event delegation to handle click events on dynamically added elements or to reduce the number of event listeners.
  4. Performance and Accessibility:

    • Lazy Loading Images: Implement lazy loading for images that are not immediately visible to improve page load times.
    • Keyboard Accessibility: Ensure that the accordion can be operated using keyboard controls for better accessibility.
  5. Code Organization:

    • Separate Concerns: Separate CSS, JavaScript, and HTML into distinct files if not already done. This makes the codebase cleaner and easier to manage.
  6. Further Learning:

    • CSS Animations: Explore CSS animations to enhance the user experience. For example, smooth transitions for accordion opening/closing.
    • Accessibility Features: Learn more about ARIA roles and properties to make your accordion more accessible.
    • Learning Resources: MDN Web Docs for detailed documentation on HTML, CSS, and JavaScript.

You've made an impressive effort in creating this FAQ Accordion. Keep up the great work and continue to challenge yourself with new and more complex projects. Your progress is excellent, and I'm excited to see what you'll create next! Keep coding and exploring! 🚀

Marked as helpful

0

@Priyanshu-WD

Posted

Hey, @petritnuredini, thank you as your comment gave me an area to work.

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