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
Request path contains unescaped characters
Request path contains unescaped characters

Submitted

QR Code Componenet using CSS Flexbox

P
nimrodEDE 140

@nimrodEDE

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

P

@Islandstone89

Posted

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 alt text must also say where it leads(the frontendmentor website). A good alt text would be "QR code leading to the Frontend Mentor website."

  • The <header> element is used for content that repeats across several pages - think of what you usually see at the top of a webpage - a logo and a navigation bar are the typical examples. "Improve your" is a heading, which is something different. I would make it a <h2> - a page should only have one <h1>, reserved for the main heading. As this is a card heading, it would likely not be the main heading on a page with several components.

  • .attribution should be a <footer>, and you should use <p> for the text inside.

CSS:

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

  • Remember to specify a fallback font:font-family: 'Outfit',sans-serif;

  • Move font-family from * to body.

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

  • On the body, change height to min-height - this way, the content will not get cut off if it grows beneath the viewport. Also, add gap: 2rem to give the footer some space underneath the main.

  • Remove the margin on the card - it is not needed since the card is centered using Flexbox on the body.

  • Remove all widths and heights in px and %.

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

  • 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 max-width: 100% - the max-width prevents it from overflowing its container. Without this, an image would overflow if its intrinsic size is wider than the container. max-width: 100% makes the image shrink to fit inside its container. Remove the margin, though you can set a margin-bottom to give the image some breathing room from the text under.

  • To create the space between the image and the edge of the card, set padding on all 4 sides of the card:padding: 16px;.

Marked as helpful

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