Design comparison
Solution retrospective
Any help to improve this greatly appreciated.
Community feedback
- @Islandstone89Posted 24 days ago
Excellent advice, Kamran!
I'll add the following:
HTML:
- The alt text should be written naturally, without using
-
between the words. 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."
CSS:
-
I recommend adding a bit of
padding
, for example16px
, on thebody
, to ensure the card doesn't touch the edges on small screens. -
Remove the margin on the card.
-
As mentioned above, setting fixed sizes is not ideal, so remove all widths and heights. Add a
max-width
of around20rem
on the card. -
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. -
Paragraphs have a default value of
font-weight: 400
, so there is no need to declare it. -
In addition to
max-width: 100%
, I also like to setheight: auto
anddisplay: block
on all images. 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;
.
Marked as helpful1 - The alt text should be written naturally, without using
- @kaamiikPosted 24 days ago
Hi. Congrats.
- Your HTML structure is good. You have a
main
element in your html that is good. and You didn't create extra div
s. But this is not a page and you don't needh1
here.h1
is like a title of your page. Useh2
instead.
- Try to use a proper CSS reset at the start of your CSS style. Andy Bell and Josh Comeau both have a good one. You can simply search on the internet to find them.
- Use
min-height: 100vh;
instead ofheight:100vh;
.height: 100vh
strictly limits the height to the viewport size, potentially causing overflow issues if the content is larger than the viewport. On the other hand,min-height: 100vh
allows your element to grow in height if the content exceeds the viewport size. Also put yourmin-height
inside thebody
.
- Never limit your width and height in a container or element or tag that contains text inside. When you limit the width and height of elements containing text, you risk the text being cut off, overflowing, or becoming unreadable, especially on smaller screens or when the text dynamically changes. It's generally better to allow the container to adjust its size based on its content or set a flexible size that can adapt to different screen sizes and text lengths. You only need
max-width
here in your.container
because it prevents elements from stretching beyond a certain point, keeping them visually appealing across different screen sizes. It ensures your design remains adaptive and doesn't get too wide on larger screens.
- For your
img
you can use width and height but in this challenge there is no need. You just needmax-width: 100%;
for your image. If you add a proper CSS reset to your style, then this is used forimg
.
- Your
font-size
andmax-width
should be inrem
unit notpx
. You can read this article about it and why you should not usepx
as a font-size.
Marked as helpful1@WrinklytechPosted 23 days ago@kaamiik thanks for your feedback, much appreciated. Just one issue; moving the min-height setting to the body causes the flex items to move to the top of the screen.
0@kaamiikPosted 23 days agoAdd the flex settings too. @Wrinklytech
min-height:100vh; display: flex; flex-direction: column; justify-content: center;
Marked as helpful1 - Your HTML structure is good. You have a
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