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

@johnabrham438

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

I am creating a front end Product preview card component challenge with html && css thank you frontend mentor for this challenge

Community feedback

@MohammedOnGit

Posted

Hello yohannes abrham!!!

Congratulation on completing this challenge. Your code is already on the right track, but here are a few suggestions and improvements to make it more robust, accessible, SEO-friendly, and aligned with best practices:

General Best Practices Semantic HTML

Use more semantic HTML elements for better accessibility and SEO. Instead of using a <section>, consider using a <article> for the card, as it represents a standalone piece of content.

Use a <figure> tag for the image, which semantically represents self-contained content (i.e., a product image). This improves both structure and accessibility. Example:

<article class="card">
  <figure class="card-img">
    <img src="images/image-product.jpg" alt="Gabrielle Essence Eau De Parfum bottle">
  </figure>
  <div class="card-content">
    <span class="perfume">Perfume</span>
    <h1 class="title">Gabrielle Essence Eau De Parfum</h1>
    <p class="text">
      A floral, solar and voluptuous interpretation composed by Olivier Polge, 
      Perfumer-Creator for the House of CHANEL.
    </p>
    <h2>$149.99 <span class="old-price">$169.99</span> </h2>
    <button class="add-to-cart"><img src="images/icon-cart.svg" alt="Cart Icon">Add to Cart</button>
  </div>
</article>

Accessibility (WCAG Compliance) Alt Text for Images

Your alt="" for the img inside the button needs to describe the image for screen readers. Something like:

<img src="images/icon-cart.svg" alt="Cart Icon">

Button Accessibility

Ensure that your button has clear and concise text that describes the action. The current "Add to Cart" is good but ensure it’s wrapped in a semantic <button> tag. Also, adding aria-label for improved accessibility is a good practice:

<button aria-label="Add Gabrielle Essence Eau De Parfum to cart">
  <img src="images/icon-cart.svg" alt="Cart Icon">Add to Cart
</button>

SEO (Search Engine Optimization) Meta Description

Add a meta description to help search engines understand your page better and improve click-through rates:

<meta name="description" content="Product preview for Gabrielle Essence Eau De Parfum - A floral, solar and voluptuous interpretation composed by Olivier Polge, Perfumer-Creator for the House of CHANEL.">

Use of Headings

You are using appropriate heading levels (<h1> and <h2>), which is great for SEO. Make sure to maintain logical heading structures across the page for better search engine visibility.

Image Optimization for SEO

Use descriptive filenames for images to improve SEO. Instead of icon-cart.svg, you could name it chanel-cart-icon.svg, for example. Performance & Optimization Lazy Loading Images

For performance, you can enable lazy loading for your product image and cart icon. This will help defer loading until the image enters the viewport:

<img src="images/image-product.jpg" alt="Gabrielle Essence Eau De Parfum bottle" loading="lazy">

Additional Suggestions CSS BEM Naming Convention Consider using the BEM (Block-Element-Modifier) naming convention for better readability and maintainability in CSS. For example:

<div class="card__content">
  <h1 class="card__title">Gabrielle Essence Eau De Parfum</h1>
  <p class="card__description">...</p>
</div>

Conclusion By making these changes, you will improve your website’s accessibility, SEO, and overall performance. These changes also help in following modern web development best practices while keeping your code clean and maintainable. I hope this helps. Happy coding!!!

0

@johnabrham438

Posted

@Aggressive-Mohammed thank you so much🙏🏾🙏🏾 for your helpful comment

1

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