Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

Simple HTML, CSS Card Using Position and Flex

Hossam Fawzy•110
@hossamfawzy777
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Simple HTML, CSS Card Using Position and Flex. I appreciate your feedback.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Richard Ogujawa 👨‍💻•170
    @RichardOgujawa
    Posted over 2 years ago

    Hi Hossam,

    I'd recommend a few things, but feel free to disagree.

    For the HTML:

    • Include a main tag around the entire card. I know it may seem redundant, but I think it's always just best practice to put main around the main content of any project you build.

    • It's not a must but I'd recommend looking into BEM Naming Convention for naming classes. It makes it easier to collab with other developers and ensures that your classes are easy to read and understand. (https://codeburst.io/understanding-css-bem-naming-convention-a8cca116d252?gi=369393261570)

    I'd recommend looking into semantic HTML too, because you used <div> a lot, for example for the paragraph you used <div class="paragraph"> as opposed to using a <p> tag.

    • I'd also recommend looking into the picture tag, it's the recommended way to load images on your sites (https://blog.bitsrc.io/why-you-should-use-picture-tag-instead-of-img-tag-b9841e86bf8b)

    • Add alt text to your icons

    • Make sure the image alt text you write is a bit more descriptive. Think of it as you describing the image to a friend who is blind. What words would you use to help them understand what they cannot see.

    • If you want to write more semantic HTML I'd recommend using the <time> tag for the '3 days left' text on the site.

    For the CSS:

    • I'd recommend not using the hsl function in your color variables. You're better off just mentioning the values (i.e. '--soft-blue: 215, 51%, 70%' instead of '--soft-blue: hsl(215, 51%, 70%)'). This will allow you to later add an alpha value if needs be. For example, if you wanted the soft-blue colour to be slightly transparent, but used the variables the way you've written it, you wouldn't have that flexibility to do so. However, if you only used the values, then you could do something like this. 'color: hsl(var(--soft-blue), 50%)'

    • Use a CSS reset to make your HTML easier to style and work with. For example Josh W Comeau's (https://www.joshwcomeau.com/css/custom-css-reset/).And to this I'd also add recommend adding something like 'h1, h2, h3 {line-height: 1.1}', because the line-heights seem to get rather big on those heading levels.

    • A faster way to center elements on in a container is using 'display: grid', and 'place-content: center'on the parent or container element. If you don't get the result you want, I'd recommend changing out 'place-content: center' with 'place-items: center'.

    • Rather than using fixed units I'd recommend using relative units like em or rem, em for spacing, padding, margins, border-radii, etc., and rem for font sizes. This makes it easier to create more responsive designs because em and rem are linked to the font size, so if you simply adjust the font size in the html you will also be adusting the spacing, padding, margins, etc. all in one line of CSS, rather than having to adjust a bunch of different margins, paddings, etc.

    Hope this helps:)

    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 1st-party linked stylesheets, and styles within <style> tags.

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.

Oops! 😬

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

Log in with GitHub