Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Product Preview Card using HTML and CSS

Andrew•20
@am4188
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Any general tips for improvement would be really appreciated. This is my first project here and I know the code is a mess so I'm sure there's a lot of room to improve. Also, I started with the desktop version and then worked on the mobile (and was later told that it's best to do the desktop version first)-- when I started working on mobile, the button was the only part of the bottom div (.preview) that was out of the position with part of it outside of the container. I tried to fix it properly but couldn't figure out the root cause so I just added some negative margins on the left side. Any idea why it was leaking out of the container in the first place?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Chamu•13,820
    @ChamuMutezva
    Posted almost 3 years ago

    Greetings Andrew and welcome to Frontend Mentor.

    HTML

    • use semantic elements such as header, main , footer etc instead of traditional elements such as divs. Semantic elements makes your site accessible among other things. Those are some of the issues that have been raised in the automated feedback.
    • when you are given images for various screen sizes , the recommended methods to display those images accordingly falls under responsive images. You can find out more here on mdn responsive images. Using css to hide and display images is not one of them - it is considered expensive for the user as it wastes bandwidth on the images that the user will not see.
    • it is very important for a site to have a heading element with the h1 being the first heading element and following a sequential order without skipping headings

    CSS

    • The body has height: 100vh - that restrict your content so that you can scroll the page if the content does not fit on the page. Changing it to min-height: 100vh will fix that issue. Apply paddings as well on the top and bottom to have some space between the body and the content
    • font sizes should not be in px , rather use rems. px values create serious accessibility barriers such as overruling the font size preferences set by users. You can get a detailed explanation here Why designers should move from px to rem (and how to do that in Figma)

    Happy coding

    Marked as helpful
  • Kate•170
    @YayoKB
    Posted almost 3 years ago

    I've only glanced at this for a bit so forgive me if this isn't incredibly constructive or helpful. :)

    1. You're using fixed widths (pixels instead of rem / em or vh, vw etc). This decreases the levels of accessibility and responsiveness, too.
    2. I haven't come across using spans the way you did. Is there any reason you did so?
    3. For some reason, .preview does not follow the same widths as its parent. That is why your button has strange sizing - it's simply following .preview which is bigger than your .container. I could be wrong though - I'm just starting out on here too.
    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub