Skip to content
Submitted about 13 hours ago

Product preview card using Semantic HTML, Flexbox & CSS variables

accessibility
LVL 1
Ivan•40
@Dubets-Ivan
A solution to the Product preview card component challenge

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm most proud of writing clean, semantic HTML—especially learning to use the <picture> element for responsive images, <s> for the old price, and aria-hidden="true" for the decorative cart icon. Next time, I would try building the layout using a mobile-first workflow from the start.

What challenges did you encounter, and how did you overcome them?

At first, my global img styles accidentally affected and cropped the small cart icon inside the button. I fixed this by targeting the main photo specifically with a .product-image class. After removing the fixed height from the card, the desktop image overflowed and pushed the text outside. I overcame this by applying flex: 1 to the direct children (<picture> and .product-info) and setting width: 100% on the image. For mobile spacing, I initially added padding to individual text elements, but then learned to replace it with a single gap property on the flex container for much cleaner CSS.

What specific areas of your project would you like help with?

I'd love any feedback on my CSS structure and responsiveness—especially how I handled the layout transition between desktop and mobile using Flexbox and media queries. Also, let me know if there are any ways I can improve my HTML semantics or accessibility!

Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Ivan’s solution.

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