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

First steps with CSS BEM and HTML5 sematic elements

Rene Sauerwein•55
@rsauerwein
A solution to the Social proof section challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hey,

my 2nd project. It feels good, as compared to the first one I was far less struggling and I definitely made already some progress.. :)

This time I tried to focus on using HTML5 semantic elements and using BEM. So I would be thankful if you could take a closer look on it.

Honestly using BEM sometimes felt weird. My CSS is now definitely more structured but I felt like I'm blowing up my code and sometimes I didn't know what to do.. Especially with nested boxes I felt like it's getting complicated. For example while creating classes like review__authorname , review__authorname I asked myself if it wouldnt be better to create classes like author__name. But I guess that way I would break BEM naming conventions.

Also the classes box-1, box-2 and box-3 were special as I asked myself if I should really create duplicate code just to follow BEM. In that example I decided to don't do it..

I would be thankful if someone more experienced has some input for me. Also all sort of other suggestions are welcome.. :)

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • ApplePieGiraffe•30,525
    @ApplePieGiraffe
    Posted over 4 years ago

    Hey, Rene Sauerwein! 👋

    Good work on this challenge! Your solution looks great and responds well! 👏

    You definitely don't have to use BEM for every single element on your page. Like emestabillo, doing so can lead to very long class names that can be kind of annoying. I like to use BEM in a way that allows me to quickly understand what things are in my code but doesn't necessarily strictly follow the Block—Element--Modifier principle. For example, I'd do what you suggested and simply write author__name rather than review__author-name if author seems like a somewhat self-contained element which would make sense to do that for. I also might do things like footer__logo even if logo isn't a direct child of footer but a container or two down in the markup (since logo is a prominent part of the footer nevertheless).

    Overall, I think you should do what works best for you while keeping the readability and understandability of your code to others in mind. 😉

    Keep coding (and happy coding, too)! 😁

  • Emmilie Estabillo•5,600
    @emestabillo
    Posted over 4 years ago

    Hey Rene, looks good! Site is responsive and awesome job with mobile-first. Just a few thoughts:

    • I'm not an expert, but I like to keep BEM nested at two levels only to avoid BEM fatigue lol. I also get lost in it sometimes. I then leave the other nested contents as separate classes. I'd also like to get others' opinion regarding this :-)

    • The five-stars and reviews divs could use the max-width property to control the stretch in medium screens. The appear really long before the breakpoint. The site may be ready for desktop design at around 900px or so.

    • For your box-n question, I would try to style the divs using nth-child if you didn't want to add another class for the staircase effect. (I hope I understood the question correctly)

    Hope this helps!

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.

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

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