
Design comparison
Community feedback
- P@Islandstone89Posted 4 months ago
HTML:
-
There is a typo in the heading - change "front-ent" to "front-end".
-
I would change the heading to 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. -
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 a page's "main" content. Add a<main>
, and inside of that a<div class="card"
that holds the card content. You can remove the div wrapping the image, it is not needed. This is how your structure should look like:
<main> <div class="card"> <img> <h2> <p> </div> </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."
-
Remove the empty
width
attribute.
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.
-
You shouldn't declare
font-family
twice on the same element! Also, you only need to set it on the body, since the children will inherit the value. So, setfont-family: 'Outfit', sans-serif;
on thebody
, and remove it elsewhere. -
It's good to have some
padding
on thebody
, to ensure the card doesn't touch the edges on small screens. However,90px
is way too much, making the card very narrow on small screens. The body only needs a little bit of padding - I usually recommend around16px
. -
On the
body
, changeheight
tomin-height: 100svh
- this way, the content will not get cut off if it grows beneath the viewport. -
max-width
on the card should be in rem. Around20rem
(equals320px
) will work fine. -
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
display: block
,height: auto
and changewidth
tomax-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.
0 -
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