@Islandstone89
Posted
HTML:
-
All images need an
alt
attribute! Decorative images should have empty alt text:alt=""
. This 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(frontendmentor website). A good alt text would be "QR code leading to the Frontend Mentor website." -
You only need one
<div>
for the card ,that holds the content. I would remove the<section>
.
CSS:
-
Including a CSS Reset at the top is good practice.
-
I like to add
1rem
ofpadding
on thebody
, to ensure the card doesn't touch the edges on small screens. -
You don't need
display: block
on thebody
- this is its default value. -
Move the properties on
qr-code
tobody
, and changeheight
tomin-height
- this way, the content will not get cut off if it grows beneath the viewport. -
align-content
should bealign-items
. -
Remove the width and height on the card. You rarely want to set fixed sizes in
px
. -
Remove the margin on the card - it is centered using Flexbox.
-
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 value of
font-weight: 400
, so there is no need to declare it. -
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
and changewidth
tomax-width: 100%
- the max-width prevents it from overflowing its container. Removealign-self: center
, it is not needed.
Marked as helpful
@HovenWebdesign
Posted
@Islandstone89 Thank you for the feedback! It is very helpful. Why is it that in the image I should use display block?
@Islandstone89
Posted
@HovenWebdesign Is is to get rid of the whitespace underneath an image if it's in a <div>
. I'm not an expert, and the difference is subtle, but my understanding is that's best practice to have images as display: block
. . This Codepen shows the difference between having display: block
and not . If you open DevTools and inspect the images without display: block
, you'll notice that they don't fill the entire height of the <div>
they are wrapped in.
Marked as helpful
@HovenWebdesign
Posted
@Islandstone89 Thank you for explaining!