@Islandstone89
Posted
Hi there. I'll try to give you as best advice as I can :)
HTML:
-
Use appropriate semantic HTML landmarks whenever needed. Instead of adding
role="main"
to a<div>
, you should use the<main>
element, which has an implicitrole="main"
. 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 the "main" section of a page. Change.wrapper
into a<main>
. -
You don't need to wrap the card content in a
<section>
, so I would remove it. -
The alt text should be written naturally, so instead of
qr-code
you would writeqr code
. However, the alt text must also say where it leads(frontendmentor.io). -
"Scan the QR code" should be a
<p>
, as it is not a heading but a paragraph. -
Do not use
<br>
to force text onto a new line. The text should flow naturally, and all styling, including space between elements, should be done in the CSS.
CSS:
-
It's good practice to include a CSS Reset at the top.
-
text-align
andfont-family
are the same for all elements, hence they should be set on the<body>
, and removed elsewhere - because of inheritance, the body's descendants will inherit the value. -
font-size
must never be in px. This is bad for accessibility, 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. -
On the image, remove the
margin-top
. Adddisplay: block
and change themax-width
to100%
- the max-width prevents it from overflowing its container. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card. -
Remove everything from
.wrapper
, except forbackground-color
andborder-radius
. You shouldn't useposition
for layouts, and I'll show you a better way to center the card. Setting widths and heights inpx
is rarely a good idea, as components won't be able to adapt to different screens. -
Do add a
max-width
of around20rem
on the card, to prevent it from getting too wide on larger screens. -
To center the card horizontally and vertically, use Flexbox on the body:
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
- About media queries, there is no need for one on this challenge, because the design doesn't change. When you do need them, they should be in rem, not px. Also, it is common practice to do mobile styles first and use media queries for larger screens.
Marked as helpful
@paradawx
Posted
@Islandstone89 thank you so much, this is better advice than I could have ever hoped for! I knew something was wrong with using px so much but i wasnt sure what the alternatives were. I'll update this file when I get a chance and keep those best practices in mind on my next few projects, thanks again!!