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 using Flex, CSS Variables & ARIA

Stephanโ€ข 60

@Kyr27

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


I'm not sure if i did ARIA correctly, any help regarding how i can improve it is appreciated.

Community feedback

@MelvinAguilar

Posted

Hello there ๐Ÿ‘‹. Good job on completing the challenge !

I have some suggestions about your code that might interest you.

ARIA ๐Ÿ”Š:

  • div elements are not interactive, so they do not require a label, and they do not work on div elements; if you use a screen reader, you will notice that no aria-label with the div, section, or main tags is announced.
  • The aria-label attributes are not required for paragraphs because the text content of the p and h1 elements is already accessible to screen readers. When the aria-label attribute is applied to a paragraph element, screen reader users will hear the text specified in the attribute's value rather than the text of the paragraph.
  • aria-label="Add to cart": Don't repeat what the cart button says in the HTML; if you change the text of the button, it's very likely that the aria-label attribute will be forgotten to update.
  • One component is not a complete page, there should not be a <header> and <footer> in the solution.

I hope you find it useful! ๐Ÿ˜„

Happy coding!

Marked as helpful

1
Stephanโ€ข 60

@Kyr27

Posted

Fixed the left and right side height mismatch that was likely caused by the way flexbox handles paddings and margins behind the scenes, by centering using body instead:

! Don't use this to center the card:

  .product-container {
    display: flex;
    justify-content: center;
    align-items: center;

    min-height: 100vh;
    margin-inline: auto;
  }

! Use this instead:

body {
   min-height: 100vh;
   align-items: center;
   justify-content: center;
}
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