Design comparison
Solution retrospective
I am proud of completing first challenge only by using my own knowledge.
What challenges did you encounter, and how did you overcome them?There a some challenges regarding size of the component. I still find it hard to decide which size to use. Normally, as in this project, I would use max-width for the components. But I am still sure if this is the best option.
What specific areas of your project would you like help with?Centering the component. I still have no clear picture of what is the best way to center a component.
Community feedback
- @Islandstone89Posted 2 months ago
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 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."
-
"Improve your" is a heading. I would make it 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.
CSS:
-
Including a CSS Reset at the top is good practice.
-
Remember to specify a fallback font:
font-family: 'Outfit',sans-serif;
-
I would recommend adding
1rem
ofpadding
on thebody
, to ensure the card doesn't touch the edges on small screens. -
box-sizing: border-box;
should be set on all elements, like this:
*, *::before, *::after { box-sizing: border-box; }
-
On the
body
, changeheight
tomin-height
- this way, the content will not get cut off if it grows beneath the viewport. -
Remove all widths in
px
. -
max-width
on the card should be in rem. Around20rem
will work fine. -
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. -
Likewise, you only need to set
font-family
on thebody
, and remove it elsewhere. -
Selectors like
.container .text-container
increase specificity, which makes them harder to override. It's best practice to use a single class selector:.text-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;
. -
On the image, add
display: block
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. Remove the margin, the only thing you possibly need is amargin-bottom
. NB: When the value is0
, you don't need to include the unit. So, instead of0px
, it is common to write0
.
Marked as helpful0@Augurk66Posted 2 months ago@Islandstone89
Thank you very much for the extensive feedback! I really appreciate the details you mention. I learned a lot and I will implement it in to the project and also use it in the next project.
1 -
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