Design comparison
Community feedback
- @Islandstone89Posted 6 days ago
HTML:
-
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(the frontendmentor website). A good alt text would be "QR code leading to the Frontend Mentor website."
-
Change
.attribution
to a<footer>
, and use<p>
for the text inside.
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. -
Remove all styles on
main
. -
Remove the margin on the card.
-
To center the card horizontally and vertically, with some space between the
main
and thefooter
, I would use Flexbox on the body:
display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100svh; gap: 20px;
-
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. -
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. -
Remove the
margin
on the paragraph. -
The paragraph text has poor contrast, making the text harder to read. Inspecting it in DevTools (open it using the
F12
key, then inspect an element usingCtrl+Shift+I
) reveals a contrast ratio of3.53
. To fullfill the Web Content Accessibility Guidelines requirements, text must have a contrast ratio of at least4.5
. Since the color is inhsl
(hue, saturation, lightness), you can make it darker by reducing thel
value. Changingcolor: hsl(220, 15%, 55%)
tocolor: hsl(220, 15%, 45%)
makes the contrast ratio5.2
, which is acceptable. -
On the image, remove
width
and replacemargin
withmargin-bottom: 20px
. Adddisplay: 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. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card:padding: 16px;
. -
Don't use complex selectors like
main .card .content p
, as it increases specificity, making it harder to override. It's best practice to give elements a class and then use that class as the selector. -
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.
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