Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Product Preview Card Component

Vinzzโ€ข 280

@Vinzz34

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

@MelvinAguilar

Posted

Hi @Vinzz34 ๐Ÿ‘‹, good job completing this challenge, and welcome to the Frontend Mentor Community! ๐ŸŽ‰

In addition to the previous comments. I have some suggestions you might consider to improve your code:

  • In this challenge, you should not use the background property to set the image because this image has semantic meaning. Use the CSS background property if the image is not part of the content.
  • 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 in your CSS file to modify the image.

Example:

<picture>
   <source media="(max-width: 50em)" srcset="./images/image-product-mobile.jpg">
   <img src="./images/image-product-desktop.jpg" alt="your alt text">
</picture>
  • You could use the <del> tag to display the old price:
<del class="wrong">
   <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.

More information here.

  • The cart icon is for decoration purposes only, so it can be hidden from screen-readers by adding aria-hidden="true" and leaving its alt attribute empty:
<img class="cart-icon" src="./images/icon-cart.svg" alt aria-hidden="true">

I hope those tips will help you! ๐Ÿ‘

Good job, and happy coding! ๐Ÿ˜

Marked as helpful

2

Vinzzโ€ข 280

@Vinzz34

Posted

@MelvinAguilar thanks a lot will definitely be using these tips for sure!

1
Adeola Ganiuโ€ข 1,320

@Deolabest

Posted

Hey @Vinzz34, Congratulations on completing this challenge!

Here is my feedback:

  • It's not a good practice to use px to set font-size. Instead use rem units, they are great since they adapt better to the font-size the user will set in the browser settings. You can convert from px to rem here: https://pixelsconverter.com/px-to-rem.

  • Use <main> instead of a simple <div> to improve the semantics and accessibility on the page. Remember that every page should have a <main> block and that <div> doesn't have any semantic meaning.

Keep doing a good job!

Marked as helpful

1

Vinzzโ€ข 280

@Vinzz34

Posted

@Deolabest thanks for the feedback i mostly used rem for font-size and also used main in the beginning but later changed it to a div thanks for the feedback though will use these tips

0

Please log in to post a comment

Log in with GitHub
Discord logo

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