Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 8 months ago

Interactive Rating Component using HTML, CSS, JavaScript

Rhys Miller•40
@rjmills87
A solution to the Interactive rating component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


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

I am very pleased with how the project has come out and how close that I appear to have got to the provided design.

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

The main challenge that I faced was the styling of the radio inputs. After a few attempts to figure this out without any assistance, I had to resort to searching for a solution online. I found a short youtube video which was really helpful (link in the project README) and I was able to adapt the methods in the video to work with this project and I am overall really happy with the results.

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

I am still not sure if the form I have created could be better structure or handled when the submission is made. I am also sure that my CSS could be optimised better and that is something I need to work on so that I am not unessessarily repeating style which could be grouped together.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted 8 months ago

    I'm afraid this has some serious accessibility problems. It's great you've used a form with radio inputs but there are specific requirements around that you need to follow.

    • This group of radios should be in a fieldset (or role="group") with a legend (or aria-labelledby referencing some on screen text).
    • there should be no click event listeners anywhere, just one submit event listener on the form.
    • the inputs must not be display none! That removes them from the accessibility tree. You need to accessibly hide them instead.
    • font size should be in rem, never px.
    • it's really important to never limit the height of elements that contain text. That includes the wrapper, and component (the cards/panels). Min-height is fine to use (but unnecessary on the component). Let the browser do it's job and decide what height is needed based on the content inside the card.
    • the component must not have a width either. Use max-width in rem instead. This allows the component to shrink narrower when needed like on smaller phones.
    • don't style on IDs. That's not what they're for and is causing unnecessary duplication in CSS.
    • don't forget to add :focus-visible styles. When the inputs are focused by keyboards it needs to be obvious on the label visually.
    • there is no need for a media query in this. Once the above changes are made you can remove it. But for future reference, don't write media queries like this. Style mobile first and use min-width media queries, preferably defined in rem or em not px so that the layout scales nicely even when users have a larger text size setting.
    • don't change inline styles in js. Let css handle all styling. Js should only toggle attributes or classes.
    • once you've changed js to only use one submit listener you will be able to get the chosen value from the form data. E.g. form.rating.value.
    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

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

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

Log in with GitHub