Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 year ago

QR code component

bem, sass/scss
Chris•30
@ks-web-workbench
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 is the first time I'm publishing code anywhere :)

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

Im not sure if my html is semantically correct.

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

I really don't know how to control line of text. I used max-width: 25ch to limit lenght of text but I don't know if it is done right. Is h2 semantically appropriate for a component header?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

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

    Hi Chris, good job!

    Here is what could be improved - I hope it helps :)

    HTML:

    • Every webpage needs a <main> that wraps all of the content, except for <header> and footer>. This is vital for accessibility, as it helps screen readers identify a page's "main" section. Wrap the card in a <main>.

    • The qr code is meaningful content and should be placed as an <img>, not as a background-image. It also needs to 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 website).

    • It is OK to use <h2> for a component header. In a real-world scenario, several components would be on the same page. There can only be one <h1> on a page, so the headings on the components are more suited as <h2>.

    CSS:

    • Including a CSS Reset at the top is good practice.

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

    • Remove the width on the card. You should rarely set fixed sizes, as components need to be able to adapt to all kinds of screens.

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

    • Remove all properties on the image, except for border-radius. Add display: block and max-width: 100% - the max-width prevents it from overflowing its container.

    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

Oops! 😬

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

Log in with GitHub