Design comparison
Solution retrospective
While designing such card components, I use the CSS property 'background-image' to design the image section. Is it best to use it in such cases or shall I opt for using the '<image>' tag in the HTML file? Any suggestions will be greatly appreciated, Hare krishna.
Community feedback
- @gautamjuyalPosted over 2 years ago
In general, using a background-image property for inserting an image require at least some content in the div, and the image may end up being scaled wrong or worst case squeezed or stretched. I think you should use <img> tag for inserting images inside divs, and in order to change the image (/image source) at hover/active states (etc.) or even for different viewports, utilize the
content: url(" ");
property for the div.Marked as helpful0@ItachidorriPosted over 2 years ago@gautamjuyal Thanks a lot, I'll use it in my future projects.
1 - @pradeeps4iniPosted over 2 years ago
Hey, Shyam. How are you?
You've done a great job on implementing the design.
You should use <img> element, along with a descriptive alt text, for the image. Because the image is not for decorative purpose. This image conveys information.
You can also use <picture> element to change the image respective to the width of the viewport.
Marked as helpful0@ItachidorriPosted over 2 years ago@pradeeps4ini Thanks for the help. I appreciate your time
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