@Islandstone89
Posted
Good job!
Some suggestions:
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" section. Wrap the card in a<main>
. -
The
<footer>
must not be outside of thebody
. The body is always the parent for all of the content on a page. Your structure should look like this:
<body>
<main>
<div class="container"></div>
</main>
<footer>
<div class="attribution"></div>
</footer>
</body>
-
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. -
Footer text must be wrapped in
<p>
.
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. -
On the
body
, removewidth: 100%
- the body is a block element, meaning it takes up the full width by default. -
I would move
font-family
tobody
, so the font is consistent on all of the elements. -
max-width
on the card should be in rem - to convert frompx
torem
, divide the px value by 16. I usually recommend20rem
, which equals320px
. -
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. -
It is standard practice to add
display: block
on images - as images are inline elements by default, this can lead to unwanted space underneath an image when it is wrapped in a<div>
.
Marked as helpful
@ElkuchWaltz
Posted
This is very helpful, thank you so much for taking the time to comment, @Islandstone89 ! As I'm still early on my coding journey, this kind of information about best practices and why they're followed is really valuable.