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

Semantic HTML tag using, Sass, BEM className

accessibility, sass/scss
Kai Liin•40
@Beginneraboutlife116
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I'm not sure about my BEM announcement and my HTML usage. I really want to get some suggestions on it. If you could give me some advice, I will really appreciate you. 🙂

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Naveen Gumaste•10,420
    @NaveenGumaste
    Posted over 3 years ago

    Hay ! Good Job Wei Kai

    These below mentioned tricks will help you remove any Accessibility Issues

    -> Add Main tag after body like it should be your container. For 1st heading or h1 tag, use header tag and then inside the header put your h1 or h2 etc . But use header tag only once in main heading element.

    Keep up the good work!

    Marked as helpful
  • Grace•32,130
    @grace-snow
    Posted over 3 years ago

    Hi

    You’re definitely misunderstanding semantic html elements here. This is one piece of content. It can be a main element for the card or nest a div/article inside that if you want. Nothing else, and no aside needed

    The figure element is not for wrapping all images. You only use figure when the content needs/ deserves a caption

    The paragraph in the card is a paragraph not a h3

    Every element that has a hover effect in a design means it is interactive. That means you must use interactive elements in these places. In this challenge that’s anchor tags wrapping the image, inside the heading, and wrapping the authors name. Essential.

    I can’t see any of the interactivity (hover styles) because those elements are missing, but beyond that another styling issue is that the card is hitting all screen edges on my phone. It needs either a little margin around it, or some padding on it’s wrapper / body element

    I hope this helps

    Marked as helpful
  • Michael Bishop•1,080
    @MikeBish13
    Posted over 3 years ago

    Nice job on the solution!

    Some feedback regarding your use of BEM and semantic HTML.

    When using BEM, just be careful of the nesting of components. For example, in one section you have card__info-title and card__info-describe. Not only can this naming convention be confused for a modifier (--title, --describe) it can also get messy and complicated very quickly. See if you can create higher level components instead and then try and re-use them throughout the entire project, adding modifiers where needed. For example, these two components could easily have been changed to card__title and card__text. This article does a great job of explaining and solving some of the pitfalls of BEM - https://www.smashingmagazine.com/2016/06/battling-bem-extended-edition-common-problems-and-how-to-avoid-them/

    As for semantic HTML, you've done a great job overall and this is a brilliant habit to get into. My advice would be to try not using a semantic element for the sake of it, and if in doubt always check the MDN docs for the full definition to see if it matches your intention. For example, I would argue that you don't really need <aside> in your article as the info in question is a crucial part of the card, rather than something indirectly related. Similarly, I would argue that <time> should be reserved for specific times or dates that could be supported by a datetime attribute, e.g 7 July, 20:00, 2h30m.

    Hope that helps.

    Marked as helpful
  • Account deletedPosted over 3 years ago

    Hi there 👋

    Congratulate on finishing your project 🎉. You did a great job 🔨

    I give some suggestions that I hope help you take your project to the next level 📈.

    1. Let's fix the background color. It does not look like the original design. Use this color for background 0D1A2D
    2. And as Naveen said don't forget to fix accessibility issues 👍

    Happy coding ☕ Maqsud

    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

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