Design comparison
Community feedback
- @Islandstone89Posted 7 days ago
HTML:
-
"scan" is the first word in a sentence, so it should have the first letter capitalized: "Scan".
-
There are 2 typos - "progects" should be "projects", and "visist" should be "visit".
-
I would change the class name on the first
<div>
tocard
, as that is more appropriate than "attribution". -
The QR code is important content, and should be placed in the HTML, not as a
background-image
. The image must have an alternative text that describes the image to screen readers. 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(the frontendmentor website). A good alt text would be "QR code leading to the Frontend Mentor website." -
You don't need to wrap the text in a
<div>
. -
It's common to give elements a class, for more precise styling.
-
In conclusion, I would have your HTML like this:
<main> <div class="card"> <img src="images/image-qr-code.png" class="qr-code" alt="QR code leading to the Frontend Mentor website."> <h2 class="heading">Improve your front-end skills by building projects</h2> <p class="text">Scan the QR code to visit Frontend Master and take your coding skills to the next level</p> </div> </main>
CSS:
-
It is best practice to write CSS in a separate file, often called
style.css
. Create one in the same folder as theindex.html
, and link to it in the<head>
:<link rel="stylesheet" href="style.css">
. -
Including a CSS Reset at the top is good practice.
-
I recommend adding a bit of
padding
, for example16px
, on thebody
, to ensure the card doesn't touch the edges on small screens. -
On the
body
, changeheight
tomin-height: 100svh
- this way, the content will not get cut off if it grows beneath the viewport. -
Remove all widths and heights in
px
and%
. -
Add a
max-width
of around20rem
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
font-size
of1rem
, which equals320px
, so there is no need to declare it explicitly. -
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
border-radius: 15px
,display: block
,height: auto
andmax-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. Removemargin-top
. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card:padding: 16px;
. -
As the design doesn't change, there is no need for any media queries. When you do need them, they should be in
rem
orem
, notpx
. Also, it is common practice to do mobile styles first and use media queries for larger screens.
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