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

QR Component using HTML and CSS (2nd iteration)

Priyanka Roy Choudhury•100
@PriyankaRC16
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hi everyone!

I have iterated and worked on my second version of the qr component page.

Any feedback will be appreciated!

Thanks

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted over 1 year ago

    For CSS I'm going to give some essential tips and principles for you to have a go at refactoring rather than going through line by line

    1. Always use a modern css reset at the start of the styles. Andy Bell has a good one you can look up and use. Be sure to read his post(s) about it properly to understand what it is and why it includes what it does
    2. Never declare font sizes in px
    3. Remove all heights and widths in this (min height is fine on the body). Never limit the height of elements that contain text. As developers we have to build robust solutions that could consume content of a different length if editors change it, or different default font sizes which many many people change
    4. Most components, this includes, only need a max-width in rem, no widths
    5. Correct colors are provided in the style guide. The text must be readable
    6. Not everything needs to be flex. Only use flex very intentionally
    7. Line height should be set with a unitless value eg 1.5. Don't rely on keywords that can differ between browsers.
    8. Text align is inherited if placed on elements higher in the DOM
    9. give the component a little margin or the body a little padding to prevent the component from ever hitting screen edges
    10. There is no need for any media query on this challenge. You will need them on future challenges so it's worth reading about how to use media queries well
    Marked as helpful
  • Grace•32,130
    @grace-snow
    Posted over 1 year ago

    This looks great now. I don't think you need the .container div at all though. All of those styles can go on the body:

    display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      min-height: 100vh;
      text-align: center;
    }
    
    Marked as helpful
  • Grace•32,130
    @grace-snow
    Posted over 1 year ago

    First things first, you need to completely rewrite the html on this I'm afraid

    • Indent your code consistently so it's readable and easier to spot bugs. Your code editor can even do this formatting automatically for you
    • always use landmarks to contain content. This should have a main (Every page should) and a footer just for the attribution
    • never have text in divs or spans alone. Think about the meaning of the content and choose appropriate meaningful elements. This component clearly has an image, a heading and a paragraph. As you move onto other challenges there will be other elements required. Take time to think that through
    • don't use inline styles (there may be exceptions to this, but they are a long long way in the future - for now, treat that as a rule)
    • the image is the most important content in this component. Yet you have given it a description of "no image". It needs a properly written description saying what it is (QR code) and where it goes (to FrontendMentor.io)
    • do not split elements to force line breaks in specific places. Line breaks will occur naturally based off the available space and any max-widths applied
    • load fonts in the html head. Google fonts will give you the exact code to use once you select the fonts and weights you need
    Marked as helpful
  • P
    gladstone28•530
    @gladstone28
    Posted over 1 year ago

    I like your solution to the QR Code component challenge. However I notice the following error: In the HTML, you are missing the closing </div> tag for the <div class="body-card"> element.

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

    You should not have a div outside main. Change .container to main, and .card to div.

  • lisztomania23•170
    @lisztomania23
    Posted over 1 year ago

    Your solution seems fine, but you did not use the 'Outfit' font. Also, why the individual div for every text line, two would have been sufficient. Consider using relative properties instead of fixed for better responsiveness like min-width and max-width. Could you reduce the font size for the attribution and fix it to the bottom, or place it as preferred.

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

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

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

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