Design comparison
Solution retrospective
This is my first attempt at a Frontend Mentor challenge or building anything in HTML/CSS.
I'm mostly unsure about the styling to get the appropriate sizing, margin, and padding. Is there a better way to set these items?
Any feedback is greatly appreciated as I continue to learn more.
Community feedback
- @MelvinAguilarPosted almost 2 years ago
Hello there π. Good job on completing the challenge !
I have some suggestions about your code that might interest you.
HTML π:
- Use the
<main>
tag to wrap all the main content of the page instead of the<div>
tag. With this semantic element you can improve the accessibility of your page.
-
Use the
<footer>
tag to wrap the footer of the page instead of the<div class="attribution">
. The<footer>
element contains information about the author of the page, the copyright, and other legal information. -
Always avoid skipping heading levels; Always start from
<h1>
, followed by<h2>
, and so on up to <h6> (<h1>,<h2>,...,<h6>). Swap the<h3>
tag with<h1>
Alt text π·:
-
The
alt
attribute should explain the purpose of the image. Uppon scanning the QR code, the user will be redirected to the frontendmentor.io website, so a betteralt
attribute would beQR code to frontendmentor.io
If you want to learn more about the
alt
attribute, you can read this article. π.
CSS π¨:
-
To center an element vertically, you should use a height to its container. In this case it is recommended to use "min-height: 100vh" so that it occupies 100% of the viewport height. e.g.: `
body { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100vh; /* Use the min-height here */ . . . } .card { /* margin: 25% 10%; */ }
- Instead of using pixels in font-size, use relative units like
em
orrem
. The font-size in absolute units like pixels does not scale with the user's browser settings. This can cause accessibility issues for users who have set their browser to use a larger font size. You can read more about this here π.
I hope you find it useful! π Above all, the solution you submitted is great!
Happy coding!
Marked as helpful2 - Use the
- @HassiaiPosted almost 2 years ago
Replace<div class="card">with the main tag, <h3> with <h1> and <div class="attribution"> with the footer tag to fix the accessibility issues. click here for more on web-accessibility and semantic html.
To center .card on the page using flexbox, add min-height: 100vh to the body. Remove the margin values in .card, they are not needed. Give .card a padding value for all the sides instead of a padding-top value. e.g:
padding: 20px
.For a responsive content which won't require a media query. Give .card a max-width value. there is no need to give .card a max-height value.
Give p and h1 the same margin-left, margin-right and margin-top values. Give p a margin-bottom value. give h1 the same font-size as p which is 15px.
Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here
Hope am helpful.
Well done for completing this challenge. HAPPY CODING
Marked as helpful1 - @nathan-codesPosted almost 2 years ago
Really great work for your first challenge Brian.
Here's a small addition though.
You could set the height of your body tag to "100vh" (i.e. -----> body{height: 100vh;}) so the card gets centered as it appears in the design images.
Great job again.
Marked as helpful1@bellygoblinPosted almost 2 years ago@nathan-codes
Thank you for the feedback. Setting 100vh makes sense and was much simpler to center the card.
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