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

Profile Card using float

Alexis•70
@alexisshy
A solution to the Profile card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted almost 3 years ago

    Hi

    I'm afraid this needs almost completely re-doing to make it responsive and make use of correct HTML semantics. Here are things that need changing

    HTML:

    • Use landmark elements. Minimally, that means use a main element for your card. If you'd included the Frontend Mentor attribution, that would go below in a footer. This is mentioned in your report and has a 'learn more' link in there
    • Img tags always need an alt attribute. You use this differently if an image is decorative Vs meaningful content (look it up)
    • Headings must always go in order and never skip a level. If this card was in a real web page, it might be appropriate for the heading to be a h3, but only if there are a h1 and h2 above it. As this is a single component on a page, use a h1. Think of headings like a contents page for a document. It will become extremely important to follow correct heading structure on full web pages
    • Use a hr for the divider line. Or use border top/bottom on another element. Don't ever add in empty divs to your html.
    • When thinking about translating a design into html, consider how the content would look and what it would be if it was totally unstyled. This Card would be an image, heading, some text and then a list with three bullet points at the end. That tells you those three stats at the end of the card should be a list with 3 list items, not headings and paragraphs. Another way to know it shouldn't be a heading is if you consider whether it would make sense as a heading on a contents page - 80K would make no sense as a heading, so cannot be one, and must be in the same meaningful element as the word that accompanies it (list item). That's what makes the content make sense.

    CSS:

    • Include a basic/modern CSS reset at the start of your stylesheet. This is always good to do as it sets some common defaults you'll want and removes some of the inconsistencies between browsers. (e.g. img tags set to display block instead of inline) Josh Comeau and Andy Bell both have good modern resets that you might want to look up.
    • Don't use floats. It's really rare you'll use floats at all in modern web development. It takes items out of the document flow and is a really outdated technique where it's very difficult to make layouts responsive.
    • Don't use absolute positioning to center a component like this. Use Flexbox or CSS grid
    • Similar, don't use relative positioning and pixel adjustments. That is not the way to create a good responsive layout and 99% of the time unnecessary
    • You should be centering text horizontally with a text-align: center on the card as all text within it is centered
    • Wrap the heading (person's name) and the age in one div and set that to display flex to line them up next to each other. If you do that you can use gap to create a little space between them. OR make them both display inline-block / inline-flex and use margin on one side of one of them to create the space between them
    • The stats list at the end, once it's been made a list can be display flex. To make the numbers stack above the words, you can wrap each in a strong tag and set that to display block so it has its own line

    I hope this is helpful. There will be more feedback beyond this, especially relating to accessibility but these are the most important points.

    It's really important you pause, learn more and refactor before continuing. At a guess I expect you've started learning frontend from some very old and outdated resources. Look at the Frontend Mentor resources page and there is loads on there that will really help you.

    Good luck

    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