Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

QR code component using html and css

@HovenWebdesign

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

I tried to use modern css to create the qr code challenge. I would like to get feedback on design, usage of html and css. If you have any other feedback, I would like to hear it too.

Community feedback

P

@Islandstone89

Posted

HTML:

  • All images need an alt attribute! Decorative images should have empty alt text:alt="". This 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 website). A good alt text would be "QR code leading to the Frontend Mentor website."

  • You only need one <div> for the card ,that holds the content. I would remove the <section>.

CSS:

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

  • I like to add 1rem of padding on the body, to ensure the card doesn't touch the edges on small screens.

  • You don't need display: block on the body - this is its default value.

  • Move the properties on qr-code to body, and change height to min-height - this way, the content will not get cut off if it grows beneath the viewport.

  • align-content should be align-items.

  • Remove the width and height on the card. You rarely want to set fixed sizes in px.

  • Remove the margin on the card - it is centered using Flexbox.

  • 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 a big accessibility issue, as it prevents the font size from scaling with the user's default setting in the browser. Use rem instead.

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

  • 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.

  • On the image, add display: block and change width to max-width: 100% - the max-width prevents it from overflowing its container. Remove align-self: center, it is not needed.

Marked as helpful

0

@HovenWebdesign

Posted

@Islandstone89 Thank you for the feedback! It is very helpful. Why is it that in the image I should use display block?

1
P

@Islandstone89

Posted

@HovenWebdesign Is is to get rid of the whitespace underneath an image if it's in a <div>. I'm not an expert, and the difference is subtle, but my understanding is that's best practice to have images as display: block. . This Codepen shows the difference between having display: block and not . If you open DevTools and inspect the images without display: block, you'll notice that they don't fill the entire height of the <div> they are wrapped in.

Marked as helpful

0

@HovenWebdesign

Posted

@Islandstone89 Thank you for explaining!

1

Please log in to post a comment

Log in with GitHub
Discord logo

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