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

Product preview card component solution using CSS Flexbox

accessibility
Zakaria•60
@zakariabelassri
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Feedback would be welcome.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Melvin Aguilar 🧑🏻‍💻•61,020
    @MelvinAguilar
    Posted almost 3 years ago

    Hi @zakariabelassri 👋, good job on completing this challenge! 🎉

    Here are some suggestions you might consider:

    • Instead of using pixels in font size, use relative units of measure like rem or em. The font size in absolute length units (px) does not allow users with limited vision to change the text size in some browsers. Reference.
    • You should have used flexbox on the section and had "flex-direction: row;" for later, when viewing on mobile devices, using a media query, change the direction with "flex-direction: row".
    • You can use a <picture> tag when you need to change an image in different viewports. Using this tag will prevent the browser from loading both images, saving bandwidth and preventing you from utilizing a media query to modify the image.

    Example:

    <picture>
       <source media="(max-width: 678px)" srcset="./images/image-product-mobile.jpg">
       <img src="./images/image-product-desktop.jpg" alt="your_alt_text">
    </picture>
    

    More information here.

    • You could use the <del> tag to display the old price:
    <del class="old-price">
       <span class="sr-only">Old price: </span>$169.99
    </del>
    

    Note that I added the <span> with the sr-only class to the del element, this will provide more information about what your old price is about.

    The sr-only class is a class that you can add to hide content visually but is only visible to screen-readers.

    • You could use a CSS Reset to remove browser built-in styles and reduce browser inconsistencies.

    Popular reset style sheets:

    • A modern alternative to CSS resets
    • CSS Tools: Reset CSS
    • Custom CSS Reset

    I hope those tips will help you.

    Good job, and happy coding!

    Marked as helpful
  • Christian Prasetya•370
    @christian-prasetya
    Posted almost 3 years ago

    Congratulations on finishing this challenge. You structure your HTML & CSS code semantically great and well structured.

    But of course there's some area of improvement:

    1. Try to apply responsive design using media queries, I know it's hard to grasp at the first time, but it's worth it for developing your skill in the future.
    2. Try to use BEM method for creating a reusable css code that will make your life easier. You can check it here.
    3. Maybe try to learn about Sass/Scss pre-processor for creating more well structured and modern CSS, it really helps a lot. I just started to implement the using of Sass/Scss and really help me to structured my stylingsheet, and creating lots of functions on CSS. Check it here

    But overall, I think you did a great job developing this challenge. Hope to see more finish challenge from you.

    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

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

Oops! 😬

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

Log in with GitHub