Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 2 years ago

Newsletter sign-up form with success message using BEM CSS

bem
Leonard•1,025
@leoikeh99
A solution to the Newsletter sign-up form with success message challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This was my first time using bem css, wanted to start using this because I thought it made working with CSS cleaner and a little bit easier and it definitely was. Also tried to write better accessibility so please give me feedback on accessibility issues and also any feedback on CSS best practices.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted almost 2 years ago

    This is pretty good but there are some accessibility issues

    1. the error should not be in a label. It should be in a paragraph and have an aria-live attribute on it and a unique ID
    2. the error should not be display none by default. Aria-live elements should be present in the dom at all times so the browser knows to watch them for changes. Instead the error element should be present just with no content inside
    3. To programmatically link the error and input, use aria-desciribedby on the input pointing to the error element's ID
    4. clamped font sizes must not use viewport units for the middle font size. Instead you must use calc to transform those viewport units into rem. This is extremely important as at the moment this is ignoring users font size settings

    Other than that all this looks good previewing on mobile

    Marked as helpful
  • Karol Binkowski•1,620
    @GrzywN
    Posted almost 2 years ago

    Great job!

    I would suggest querying all the elements first and then passing them as function parameters. Then you can use the same elements and it is not necessary to query them again. This is generally considered a good practice.

    It is also better to avoid complicated regular expressions, as they almost always do not work as intended. I would suggest using one of the popular npm libraries in this case.

    Keep coding and have a nice day!

  • Mandriva 19•330
    @mandriva19
    Posted almost 2 years ago

    hello, the project is very well made. I like the fact that you are aware of accessibility features and used BEM in your CSS. I want to implement it in my future projects aswell. CSS is well written and name convention also in HTML looks nice. learned a lot from your code! thanks. keep up! <3





    one little detail tho: there is no error message popping up when user enters invalid email :P




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.

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

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