Reponsive product preview card component using HTML and CSS only
Design comparison
Community feedback
- @VCaramesPosted about 2 years ago
Hey @opeyemi-code, some suggestions to improve you code:
-
Stay away from IDs when naming your content. They are not reusable and are mainly used for JavaScript. Its best practice to use, Classes for your naming convention as classes are reusable, making them ideal for CSS styling.
-
For this challenge you want to use the Picture Element not the Background Image Property. The Background Image Property is mainly used on decorative images NOT images that add value and serve a purpose.
Picture Element will allow your to switch between images in different breakpoints and makes your site load faster by saving bandwidth.
Syntax:
<picture> <source media="(min-width: )" srcset=""> <img src="" alt=""> </picture>
Source:
https://www.w3schools.com/html/html_images_picture.asp
https://web.dev/learn/design/picture-element/
-
The old price is not being announced properly to screen readers. You want to wrap it in a Del Element and include a sr-only text explaining that this is the old price.
-
To improve the accessibility of your content, you wan to to use em instead of px for you media queries. By using px your assuming that every users browser (mobile, tablet, laptop/desktop) is using a font size of 16px (this is the default size on browser). Em's will help with users whose default isn't 16px, which can sometimes cause the your content to overflow and negatively affect your layout.
More Info:
https://betterprogramming.pub/px-em-or-rem-examining-media-query-units-in-2021-e00cf37b91a9
Happy Coding! 👻🎃
0@opeyemi-codePosted about 2 years agoThanks I appreciate the review. I'm going to fix those issues as soon as possible @vcarames
0 -
Please log in to post a comment
Log in with GitHubJoin 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