Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

FAQ Accordion Card Without JavaScript

Alisha•20
@AlishaSo
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Does anyone know how to make the background-position more static? I needed the flexibility of the percentages but they do not scale down well.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Raymart Pamplona•16,040
    @pikapikamart
    Posted over 3 years ago

    Hey, great job on this one. Desktop layout is great, however the responsiveness and mobile state should be addressed since right now, resizing the layout until mobile breakpoint, the image is just gone since it is small, and the mobile state, the contents are being hidden.

    Elaine already gave great tip on this, just going to add some suggestions as well:

    • Avoid using height: 100% or 100vh on a large container like the html and body tag as this limits the element's height based on the remaining screen's height. Instead use min-height: 100vh, this takes full height but lets the element expand if needed.
    • Those decorative images on the site could have use an extra aria-hidden="true" attribute so that they will be totally hidden alongside with the alt=""
    • You don't need to use header on this one since this just looks like a main component of a page. You can just use div on the FAQ.
    • Using checkbox on this is not really suited since there are more accessible and suited elements to be use, also do not use display: none on an input element, don't, you are removing this completely on the dom, visually using mouse you can click the label right but it is limited to that, you can' use keyboard or screen-readers.
    • Instead, a good approach to avoid extra manipulations, you could use details element for each accordion. This is much suited and accessible from the start.
    • Also right now, clicking all the accordion overlaps the container, you might want to check that one out.
    • Lastly, just the responsiveness and the mobile view needs to be adjusted.

    Aside from those, great work again on this one.

    Marked as helpful
  • Elaine•11,360
    @elaineleung
    Posted over 3 years ago

    Hi Alisha, I just completed this challenge as well; you can have a look at my repo and see if that helps: https://github.com/elaineleung/frontendmentor/tree/main/accordioncard

    I see in your live site that the text overflows outside of the card when all of them are clicked. I checked out your code but I couldn't figure out how the questions and answers are being expanded as I can't find your JS file, and the HTML doesn't show the link either. Anyway, you can check out my live site and see whether that's something you're looking for, and hopefully my code can help you out. Good luck!

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub