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

FAQs accordion

sass/scss, accessibility
Ibrahim Morad•380
@IbrahimMurad
A solution to the FAQ accordion challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Imre Bartis•60
    @imrebartis
    Posted 4 months ago

    @IbrahimMurad

    You're welcome!

    Reusable variables

    • I mean something like $spacing-sm: 1rem e.g.

    Hover color

    • The hover color in Figma I mentioned above is hsl(290deg 80% 53%)

    Project structure

    • The src folder should be in the root folder of your project. It would contain the index.html, the script.js and a styles folder containing the style files (style.sass, style.css and style.css.map)

    Let me know if you need any more clarifications!

    Marked as helpful
  • P
    Imre Bartis•60
    @imrebartis
    Posted 4 months ago

    User experience

    • When clicking on an .accordion__question the accordion item toggles, unless you happen to click somewhere between the .question open and the button. The cursor is a pointer even in places like this, so the user expects the accordion item to toggle in such cases
    • After clicking on a .question open you can't toggle the accordion item with Enter or Space. You can do that though if you have clicked on a button
    • If the user navigates by using Tab, it's only the buttons that get focused (and not both the .accordion__question and the button)

    Readme

    • Consider adding What I learned and Continued development sections

    HTML structure and accessibility

    • Neat usage of <picture> for handling responsive images
    • Good usage of semantic elements
    • Heading elements are not in a sequentially-descending order (h1 and h3 used instead of h1 and h2)
    • The aria-controls attributes have incorrect references (multiple buttons point to #answer2)
    • The accordion structure should be wrapped in e.g. a <section> with an area-label and a role="region"
    • The empty buttons have no aria-labelledby
    • Consider adding a <span class="sr-only">Toggle answer</span>inside of the empty buttons, for screen reader support
    • Consider adding role="banner" to the header
    • Consider making more descriptive the alt text of the background image
    • Consider adding keyboard shortcuts for navigating between accordions (up/down arrows), and add the keyboard navigation focus styles

    JavaScript

    • Consider adding keyboard support for Enter and Space

    Layout and styles

    • The hover color of the .question opens is different from the one in Figma
    • Mobile view styles are missing
    • Consider creating reusable variables for spacing

    Project Structure

    • Consider using a src folder
    Marked as helpful

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