Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 9 months ago

QR Code Component using HTML/CSS

Evan Lovett•30
@NotNotEvan
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

This was a great refresher on basic HTML/CSS. For my day job I typically use MUI components - so, although the CSS is syntactically similar, it was great to get back to the roots and write basic CSS outside of an sx prop. For the next project, I think I'll have an overall better approach to styling the various elements of the page because of this project.

What challenges did you encounter, and how did you overcome them?

My biggest challenges came from writing in vanilla HTML/CSS again. It's been roughly a year since I've worked in these languages to build a webpage, so that was slightly challenging at times. I overcame this by researching/reading articles - big thank you to the authors of articles on Medium!

What specific areas of your project would you like help with?

No specific areas. However, any feedback is greatly appreciated!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted 9 months ago

    Hi & well done on completing the first draft! This looks pretty good but there are a few problems and a few learnings to apply.

    • try to think of this as a single component that could be dropped into a website on any page. With that context in mind, it highlights some things. Like the alt text on the image should describe what the image is (QR code) and where it goes (to FrontendMentor.io).
    • similarly, this card would never be used to serve the main heading on a page. So you know it shouldn't have a h1. Use a lower importance heading level like h2 instead.
    • remove the inline styles from the html. Styles belong in the css. You don't want to end up with a mish mash of css styles and inline styles.
    • if links open in a new window/ tab like those in the footer, make.sure you warn screen readers. Usually that's done with some sr-only text in a span inside the link or via the title attribute saying something like "(opens in a new tab)".
    • get into the habit of including a full modern css reset at the start of the styles in every project. Andy Bell or Josh Comeau both have good ones you can look up and use.
    • This solution is getting badly cropped on some screen sizes because the height of the body has been limited with a height property. You never want to limit the height of elements that contain text, including the body. Instead of height 100dvh, use min-height and I think svh will work better for performance.
    • similarly, the card must not have a limited height. Remove the max height property from the component. Let the browser do it's job and decide what height is needed based on the content and any vertical spacings inside.
    • the body doesn't need it's width setting either. The body is already full width, which is exactly what you want so there is no need for extra.
    • change the component max width to rem instead of px. That way, if end users have a different text size the layout will scale nicely. If you leave the max width in px the end result for those people could be a narrow card with huge text squished inside it.
    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