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

Profile Card Using CSS Flexbox

accessibility
Christine Belzie•30
@CBID2
A solution to the Profile card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


During this challenge, I initially used the <article> tag to build the card in a semantic way, but someone told me that using the <div> tag. I also struggled with picking px amounts when using properties like margin and padding, and positioning elements. In the future, how can I improve on these two issues?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Adriano•42,870
    @AdrianoEscarabote
    Posted over 2 years ago

    Hi Christine Belzie, how are you?

    I really liked the result of your project, but I have some tips that I think you will enjoy:

    As you know this project is based only on one page component, so no h1 is needed! because we don't know if this page will have a more important component, but it's always good to prevent accessibility errors so I think it would be good for you to add an h1 in this component, besides being a good practice for when you are developing larger sites, don't worry forget about h1.

    To centralize your prefer to do this:

    body {
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        flex-direction: column;
        justify-content: center;
        min-height: 100vh;
    }
    

    The rest is great!

    I hope it helps... 👍

    Marked as helpful
  • Grace•32,130
    @grace-snow
    Posted over 2 years ago

    Hi

    I think this needs some more work as the html structure isn't quite right and it doesn't yet look like the design when I'm viewing on mobile (I'll add a screenshot to slack for you)

    Html

    • you don't need to wrap everything in a div
    • only use headings when they are actually headings for other content. London is not a heading, for example
    • think about how the statistics (stats) would be written in a plain unstyled document. These each have to be read together, number and word, to make sense. "80k followers" not "80k" and then a new paragraph. That indicates this needs to be a list with 3 list items, one for each stat. You can wrap the number in a strong tag or span and style as display block so it sits on its own line in the card
    • the attribution needs to be a footer element. Landmarks shouldn't be nested at different levels. Remember you can place classes directly on main / footer you don't always need to nest extra divs unless it's really needed
    • Indent your code consistently! This is Really hard to read at the moment. Your code editor can even do this formatting automatically for you
    • decorative images like the pattern at top of the card should have empty alt
    • you cannot have a header in a card and a header cannot contain only decorative (effectively no) content

    Css

    • again, format. Give the styles some.space to breathe with space between each declaration
    • the card should not have a width or height only a max-width
    • give the card a little margin on all sides
    • I don't think the background circles can be positioned correctly using px values. This is really tricky actually and I ended up using pseudo elements if you want to take a look at my solution
    • not sure why the card is position relative
    • font size must never ever be in px. I can't stress this enough. Use rem. Extremely important for an accessible site
    • never style on IDs. That's not what they are for and increases css specificity for no reason. Prone to bugs in larger projects as developers wouldn't expect changing ID to affect styling
    • use colors from the style guide not key words
  • ‪Bilal Salmi‬‏•250
    @BilalSalmi
    Posted over 2 years ago

    Hi Christine, good effort!

    Your design needs some optimization which are as follows:

    1. consider to use alt attribute in your <img> tag .

    read more about alt attribute and html images here.

    1. consider to use <h1> tag in your page.

    Read more about html heading here.

    1. to center your card consider to use css height in your html body

    for example : height: 100vh. it will perfectly center it

    keep it up!

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.

Oops! 😬

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

Log in with GitHub

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