Design comparison
Community feedback
- @Islandstone89Posted 24 days 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 a page's "main" content. Change the first<div>
to a<main>
. -
You don't need to wrap either the image or the text in their own
<div>
- all you need is a<div>
holding the card content inside a<main>
. -
The alt text should be written naturally, without using
-
between the words. 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." -
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.
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. -
It's not common to set styles on
html
, so remove those. -
Move the styles on
.container
to thebody
. Remove thewidth
, as thebody
and other block elements take up the full width by default. Changeheight
tomin-height: 100svh
- this way, the content will not get cut off if it grows beneath the viewport. -
Add a
max-width
of around20rem
on the card, to prevent it from getting too wide on larger screens. -
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. -
Likewise, set
font-family
on thebody
, and remove it elsewhere. Don't forget to specify a fallback font:font-family: 'Outfit',sans-serif;
-
Well done for having
max-width: 100%
on the image! I would also addheight: auto
anddisplay: block
. -
Use
px
instead of%
forpadding
. To create the space between the image and the edge of the card, setpadding
on all 4 sides of the card:padding: 16px;
. -
Remove all media queries. As the design doesn't change, there is no need for any of them. 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. -
Complex selectors like
.content > .image > img
increases specificity, which makes the styles applied harder to override. It's best practice to give elements a class, and select that to style.
3@krishna123-pngPosted 23 days ago@Islandstone89 Thanks for suggestions I'll try improving the mistakes that you've mentioned.
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