Design comparison
Solution retrospective
I did it!!!!
What challenges did you encounter, and how did you overcome them?Text sizing and wrapping was a little challenging, I used the tag to get it exact although I'm convinced there's a better way.
What specific areas of your project would you like help with?Setting color theme variables and sizing text and image effectively. Also adding the attributions directly under the component would be a nice addition that I did not figure out.
Community feedback
- @Islandstone89Posted about 16 hours 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" content. Wrap the card in a<main>
. -
You don't need to wrap the image or the text in a
<div>
, so remove those. Move theqr-image
class to the image, and give the heading and the paragraph a class too. -
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. -
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. -
If you want to include the attribution, uncomment it in the HTML. Change the
<div>
into a<footer>
, and wrap the text in a<p>
, as text must never be in a<div>
alone.
CSS:
-
Including a CSS Reset at the top is good practice.
-
I recommend adding a bit of
padding
, for example16px
, on thebody
, to ensure the card doesn't touch the edges on small screens. -
On the
body
, changeheight
tomin-height: 100svh
- this way, the content will not get cut off if it grows beneath the viewport. Removewidth
, as block elements like thebody
take up the full width by default. You can also remove thefont-weight
, as400
is the default value. -
If you include the attribution, you must add
flex-direction: column
andgap: 2rem
on thebody
. -
Remove all widths and heights in
px
. We rarely want to give a component a fixed size, as we need it to grow and shrink according to the screen size. -
We do want to limit the width of the card, so it doesn't get too wide on larger screens. To solve this issue, give the card a
max-width
of around20rem
. -
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. -
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
,height: auto
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. Removemargin-top
. -
To create the space between the image and the edge of the card, set
padding
on all 4 sides of the card:padding: 16px;
.
0 -
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