@Islandstone89
Posted
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. Change.container
to a<main>
. -
For the 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."
-
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. -
.attribution
should be a<footer>
, and you should use<p>
for the text inside. The footer needs to be outside of the main, not inside it.
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.
-
I like to add
1rem
ofpadding
on thebody
, to ensure the card doesn't touch the edges on small screens. -
Move
background-color
fromhtml
tobody
. -
Move the properties on
.container
tobody
. You can remove the.container
selector, as it doesn't need any styles. Changeheight
tomin-height
- this way, the content will not get cut off if it grows beneath the viewport. Addflex-direction: column
(makes the footer go under the main instead of beside it) andgap: 2rem;
(creates space between the main and the footer). -
Remove
display: inline-block
on the card, it is not needed. -
Remove
justify-content: center
on the card - it doesn't work without first declaringdisplay: flex;
. However, this is not needed. -
Remove all widths and heights in
px
- it is rarely smart to apply fixed sizes, as it prevents components from adapting to different devices. -
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. -
letter-spacing
must also never be inpx
. You can useem
, where1em
equals the font size of the element. -
On the image, add
display: block
andmax-width: 100%
- the max-width prevents it from overflowing its container. Remove the margin. If needed, you can addmargin-bottom
to separate it from the text. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card:padding: 1rem;
. -
I would use
px
instead of%
onborder-radius
.