Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

QR Code Component Main

dpiskov•50
@dpiskov
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I'm still very new to html and css, only 1 month in, so I'll appreciate any advice on how to improve my skills! :)

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Øystein Håberg•13,260
    @Islandstone89
    Posted over 1 year ago

    HTML:

    • Do not remove the <main>, it is essential to have. And you have the card as .container, which is perfectly fine.

    • The image has meaning, so it must have proper alt text. Write something short and descriptive, without including words like "image" or "photo". Screen readers start announcing images with "image", so an alt text of "image of qr code" would be read like this: "image, image of qr code". The alt text must also say where it leads(frontendmentor.io).

    • .attribution should be a <footer>, and its text must be wrapped in a <p>.

    CSS:

    • Performance-wise, it's better to link fonts in the <head> of the HTML than using @import.

    • It's good practice to include a CSS Reset at the top.

    • Add around 1rem of padding on the body, so the card doesn't touch the edges on small screens.

    • You don't need to set anything on html, so I would remove that selector.

    • Remove all of the position properties, they are not meant to be used for layout.

    • To center the card horizontally and vertically, use Flexbox on the body:

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100svh;
    
    • Move background-color and border-radius from main to .container. Remove the width and height in px - you rarely want to set fixed dimensions, so this is something to keep in mind.

    • Add a max-width of around 20rem on the card, to prevent it from getting too wide on larger screens.

    • font-size must never be in px. This is bad for accessibility, as it prevents the font size from scaling with the user's default setting in the browser. Use rem instead.

    • Since all of the text should be centered, you only need to set text-align: center on the body, and remove it elsewhere. The children will inherit the value.

    • Paragraphs have a default value of font-weight: 400, so there is no need to declare it.

    • On the image, add display: block. Remove height: auto, as that is the default value.

    • As the design doesn't change, there is no need for any media queries. When you do need them, they should be in rem, not px. Also, it is common practice to do mobile styles first and use media queries for larger screens.

    Hope this helps :)

    Marked as helpful
  • idukpaye alex•685
    @Esesosa-max
    Posted over 1 year ago

    Great Attempt, Approach Could be better (70 /100)

    1. Great Design, pretty much pixel-perfect
    2. Do not use a <main> tag to make a card because it is not semantically correct
    3. Read HTML Semantics, it is okay to use multiple divs
    4. So next time, use a <div> and give a class of container or use another tag but do not a <main>
    5. Try using CSS variables it is nice!
    6. Do you know Flexbox? or CSS Grid?
    7. if not learn it, it will make centering much much easier
    8. Not Quite impressed, with the way you centered the <main>
    9. Not Quite Responsive but the way you did it was smart
    10. Good Usage of Relative units like em or rem
    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.

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