Design comparison
Solution retrospective
I have some questions related to best practices:
-
In the style.css, I have used pixel unit for the card's border-radius and box-shadow (lines 27, 28 31). I wonder if pixels are acceptable in these scenarios since pixels are not recommended for font size and line-heights.
-
In style.css, line 137, the subtext: "Scan the QR code to ...." has extra space on its left and right. I handled it by adding padding. Is the usage of padding acceptable in this scenario?
Community feedback
- @Islandstone89Posted 12 months ago
Hi, good work on the challenge! Among other things, you are using semantic HTML elements (
<main>
and<footer>
), Custom Properties, and a proper CSS Reset.Here are a few tweaks that would improve your solution even further.
HTML:
-
I'm not an accessibility expert, but I'm not sure if you should use
aria-describedby
in addition to having alt text. -
Footer text needs to be wrapped in a
<p>
.
CSS:
-
Add
min-height: 100vh
on thebody
to center the card vertically. The reason it is not centered vertically, even though you're usingjustify-content: center
, is because thebody
by default is only as tall as its content, meaning there is no available vertical space to center the card in -
Remove
max-height
on the card. -
Remove the
height
andwidth
on the image. You have already set the necessarymax-width: 100%
in the CSS Reset. -
Instead of writing
text-align: center
on 3 different elements, you can put it on the body - this way, the elements will inherit the value, and you get the same result with less code. -
Remove
max-width
on thefooter
.
Marked as helpful1@rupali317Posted 12 months agoHello @Islandstone89
Thank you for taking the time to review my code :D I have some thoughts/clarifications for some of the comments
HTML
- The reason I added the
aria-described
was that I wanted to form a connection between the subtext "Scan the QR code..." and the main QR image. This can be handy for blind users who can rely on assistive technology to understand the connection between those two. - Agreed! Using
<p>
tags helps convey the semantic structure of the document.
CSS
- The
min-height:100vh
that you suggested adding is already part of the CSS reset. - The suggestion related to removing
max-height
on the card, is it because it is redundant? - Initially, I did not have
width
andheight
on the image. I just had the dimension set in the CSS, as you mentioned. However, when I ran the page in PageSpeed, Insights, it required me to specify thewidth
andheight
as part of the attributes to prevent CLS issues. - Agreed! Good catch!
- The reason I added
max-width
on thefooter
is specifically for smaller screens. I noticed that in small screens, the entire text was hitting the vertical edges of the screen. In order to provide some breathing space in smaller screens, I added themax-width
so that it at least wraps in two lines.
Looking forward to your response. I appreciate your help
1 -
- @danielmrz-devPosted 12 months ago
Hello @rupali317
About your questions:
-
box-shadow
andborder-radius
are parts of the project that are not likely to change. They are visual details and probably won't affect the user experience. So I thing it's acceptable using pixels. -
You used
padding
correctly to handle the extra space. Since this project is the same both on mobile and desktop versions, it won't be a problem.
I hope it helps!
Great job!
Marked as helpful1 -
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