Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 4 years ago

FAQ accordion card mobile first, no javascript!.

Foued•655
@Foued80
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


FAQ accordion card mobile first design, no javascript using checkbox hack, css only.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

  • Agata Liberska•4,075
    @AgataLiberska
    Posted about 4 years ago

    Hi @Foued80, nice work on this challenge, especially positioning images! Some things need adjustments though - have a look at the mobile layout on smaller viewports (there really should be some space between the edge of the viewport and the card), as well as what happens when you toggle all questions on desktop layout - the heading is overflowing slightly. I would also change the transition time: 1.5s is way too long in my opinion, 0.5 would be more than enough.

    Also, I'm not sure about the checkbox hack. Have a look at the report - your HTML is not validating because <div>s are not allowed inside <label>. The div that contains the question text is completely unnecessary, just have the text on it's own - it's inside the <label> tag. I guess you could move the answer div outside the label and then use the adjacent sibling combinator + in your CSS to get your HTML to validate, something like this

    <li>
      <label for="toggle1">
         <input type="checkbox" id="toggle1">
         How many team members can I invite?
         <img class="arrow" src="images/icon-arrow-down.svg" alt="">
      </label>
      <div class="card_faq_a">
           You can invite up to 2 additional users on the Free plan. There is no limit on team members for the Premium plan.
      </div>
    </li>
    

    However, this is also not very accessible. As you set input display: none, a user cannot use tab key to access the questions. You could correct that by hiding the input itself in an accessible way and adding some styles to the label when input is in focus (you could maybe use :focus-within pseudoselector). It would work better but could still be confusing to screen reader users.

    If you really want to avoid JS, you could look into using details and summary HTML elements but there are some accessibility concerns there, too. It's definitely something worthwhile to research though :)

    Hope this helps, let me know if you have any questions!

    Marked as helpful
  • Foued•655
    @Foued80
    Posted about 4 years ago

    Thank you for the feedback, here what i fixed :

    • Mobile display down to 320px.
    • LABEL html validation issue:
    <li>
                <input type="checkbox" id="toggle1" />
                <label for="toggle1">How many team members can I invite?</label>
    
                <img class="arrow" src="images/icon-arrow-down.svg" alt="" />
                <div class="card_faq_a">
                  You can invite up to 2 additional users on the Free plan. There is
                  no limit on team members for the Premium plan.
                </div>
              </li>
    
    • Lowered transition to 0.5s;

    On desktop view :

    • Added shadow to the box and fixed the positioning;
    • Reduced font-size, paddings and margins to fix the accordion display when fully expanded;
    • Added hover effect on questions (color, cursor)

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 all CSS, SCSS and Less files in your repository.

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.

How does the JavaScript validation report work?

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

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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