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 Main

dpiskov 50

@dpiskov

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


I'm still very new to html and css, only 1 month in, so I'll appreciate any advice on how to improve my skills! :)

Community feedback

P

@Islandstone89

Posted

HTML:

  • Do not remove the <main>, it is essential to have. And you have the card as .container, which is perfectly fine.

  • The 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.io).

  • .attribution should be a <footer>, and its text must be wrapped in a <p>.

CSS:

  • Performance-wise, it's better to link fonts in the <head> of the HTML than using @import.

  • It's good practice to include a CSS Reset at the top.

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

  • You don't need to set anything on html, so I would remove that selector.

  • Remove all of the position properties, they are not meant to be used for layout.

  • To center the card horizontally and vertically, use Flexbox on the body:

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100svh;
  • Move background-color and border-radius from main to .container. Remove the width and height in px - you rarely want to set fixed dimensions, so this is something to keep in mind.

  • 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 bad for accessibility, 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.

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

  • On the image, add display: block. Remove height: auto, as that is the default value.

  • As the design doesn't change, there is no need for any media queries. When you do need them, they should be in rem, not px. Also, it is common practice to do mobile styles first and use media queries for larger screens.

Hope this helps :)

Marked as helpful

1

dpiskov 50

@dpiskov

Posted

@Islandstone89 Wow, that's a lot of useful information, thank you! I appreciate it a lot! I'll take my time soaking this information up and try hard to understand it! :)

1

@Esesosa-max

Posted

Great Attempt, Approach Could be better (70 /100)

  1. Great Design, pretty much pixel-perfect
  2. Do not use a <main> tag to make a card because it is not semantically correct
  3. Read HTML Semantics, it is okay to use multiple divs
  4. So next time, use a <div> and give a class of container or use another tag but do not a <main>
  5. Try using CSS variables it is nice!
  6. Do you know Flexbox? or CSS Grid?
  7. if not learn it, it will make centering much much easier
  8. Not Quite impressed, with the way you centered the <main>
  9. Not Quite Responsive but the way you did it was smart
  10. Good Usage of Relative units like em or rem

Marked as helpful

1

dpiskov 50

@dpiskov

Posted

@Esesosa-max Thank you for the suggestions! About the parts you're not impressed about, could you give me an example of how I could've made and centered this card? Because I cannot quite understand everything you're telling me for now and I'd appreciate to see a better approach.

0

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