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

Stats preview card component using CSS Grid, Flexbox and BEM method

bem
Putu Rele Bhayu Sakti•170
@lere22
A solution to the Stats preview card component 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

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

    Hello

    not sure why you have tagged this with #accessibility? Do you think you've done something specifically to address that?

    1. This is not how you use the picture element! You are missing all the built-in performance benefits the browser gives you with this element. Look it up on MDN and use it properly. You should not be messing with any display properties in the css
    2. If you think this is a valuable image, you must describe it properly in the alt attribute. You never write words like 'image' in alt as it is already an image element. The alt has to either describe what the image looks like, or it should be left empty if the image is decorative.
    3. The image is distorted at some screen sizes - use the object-fit property to fix it.
    4. Do not do this on the html element! font-size: 0.938rem; This changes the value of 1rem and will mess with user's font size preferences. If you want to change the base font size for text on a site, place that on the body element and it will inherit to everything except form-related elements.
    5. The text area of the card is not a section element. You have an alt on that image, which meants you are treating it as meaningful content - That means this is allllll one component, an image and some text. So you could place a section element around the whole card, but you shouldnt be making just one inner part of it a section. But overall, sections are unnecessary in this challenge. They act just like divs unless labelled so it makes little difference, it's just a bad habit to get into if you use them inappropriately.
    6. Text should never be in a div or span alone. Always use a meaningful element like paragraph, list, heading, button etc
    7. The detail__stats here should be an unordered list with 3 list items inside, one for each stat (number + word). Those numbers can be wrapped in a strong or span with a class set to display block so they sit on their own line.
    8. A quick accessibility note once you change that to a list and list items - Setting the list style to none will remove the list semantics for some screenreaders. The easiest way to remedy that is by adding role="list" to the ul and role="listitem" to each li.
    9. Some of the text on this is unreadably small! Try to get that closer to the design
    10. You are missing a mix-blend mode to get the correct purple color on the image. i expect you will need to change opacity on the image to about 0.7 once that's done.
    11. Try not to place paddings on elements like paragraphs. Usually the line breaks will happen based off the parent elements padding (i.e. the available space) and you shouldn't worry about it. However if you do need to limit the width of a paragraph, it would be much better to use max-width (usually in ch units)
    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.

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