Design comparison
Solution retrospective
Hi, I'm Kingsley and this is my solution to the qr-code-component-main challenge. I found this very interesting because i got a chance to recollect what i have a long time ago cos i haven't being coding for a while now. I hope it looks great to you all and any correction and suggestion will be much welcomed.
Community feedback
- @danielmrz-devPosted 11 months ago
Hello @Kingsleigh-Obi!
Your solution looks great!
I have a couple of suggestions for improvement:
- In order to make your HTML code more semantic, and since that is the main title of the screen, replace the
<h3>
with<h1>
. Unlike what most people think, it's not just about the size and weight of the text.
The
<h1>
to<h6>
tags are used to define HTML headings.<h1>
defines the most important heading.<h6>
defines the least important heading. Only use one<h1>
per page - this should represent the main heading/subject for the whole page. Also, do not skip heading levels - start with<h1>
, then use<h2>
, and so on.- Also, still about semantic HTML, replace your
div.container
withmain.container
.
All these tag changes may have little or no visual impact but they make your HTML code more semantic and improve SEO optimization as well as the accessibility of your project.
I hope it helps!
Other than that, great job!
Marked as helpful1 - In order to make your HTML code more semantic, and since that is the main title of the screen, replace the
- @Islandstone89Posted 11 months ago
HTML:
-
Every webpage needs a
<main>
that wraps all of the content, except for<header>
andfooter>
. This is vital for accessibility, as it helps screen readers identify the "main" section of a page. Change.container
into a<main>
. -
The alt text should never include words like "image" or "photo", because screen readers will announce an
<img>
saying "image,", followed by the alt text. It also needs to say where it leads (frontendmentor.io). -
Headings should always be in order, so you never start with a
<h3>
. Change it into a<h1>
. -
.attribution
should be a<footer>
, and its text must be wrapped in a<p>
.
CSS:
-
Always include a CSS Reset at the top.
-
On the
body
, changeheight
tomin-height
- this way, the content will not get cut off if it grows beneath the viewport. Also, addflex-direction: column
andgap: 2rem
, to create space between the card and the footer. -
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 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. -
Remove all widths.
-
Add a
max-width
of around20rem
on the card, to prevent it from getting too wide on larger screens. -
Remove
margin
on the image. Adddisplay: block
and replacewidth
withmax-width: 100%
- the max-width prevents it from overflowing its container. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card. -
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.
Marked as helpful1@Kingsleigh-ObiPosted 10 months ago@Islandstone89 Thank you so much for the detailed correction. I have made the necessary correction and it improved my code immensely. Thanks again Sir.
1 -
Please log in to post a comment
Log in with GitHubJoin 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