Design comparison
Solution retrospective
This challenge was fairly easy, but I am new to the world of frontend development. I'm sure there are some things in the code that could be cleaner or more efficient, so I would love any feedback.
Community feedback
- @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 or grid instead of a margin value, add min-height:100vh; display: flex; align-items: center: justify-content: center; or min-height:100vh; display: grid place-items: center to the body.
To center .card on the page using flexbox: body{ min-height: 100vh; display: flex; align-items: center; justify-content: center; }
To center .card on the page using grid: body{ min-height: 100vh; display: grid; place-items: center; }
There is no need to give .card a margin value and a height value. Give .card the same padding value for all the sides.
padding:16px
. Give the img a max-width of 100% instead of a fixed max-width value.Give .text-container a margin value for all the sides, text-align: center and a font-size of 15px which is 0.9375rem, this will be the font-size of both p and h1.
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 helpful0 - @MelvinAguilarPosted almost 2 years ago
Hello π. Congratulation on successfully completing your first challenge π ! !
I have some recommendations regarding your code that I believe will be of great interest to you.
HTML π·οΈ:
- Use semantic elements such as
<main>
and<footer>
to improve accessibility and organization of your page.
- Always avoid skipping heading levels; Starting with <h1> and working your way down the heading levels (<h2>, <h3>, etc.) helps ensure that your document has a clear and consistent hierarchy. Source π
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 π¨:
- You should use the
box-sizing: border-box
property to make thewidth
andheight
properties include the padding and border of the element. This will make it easier to calculate the size of an element. You can read more about this here π.
- For a responsive component, consider add more
padding
to avoid border touching the image (padding: 20px;
instead ofpadding: 20px 10px 10px 10px;
). Also, setmax-width: 100%
for the image to fit the size of the component.
-
To center the component in the page, you should use Flexbox or Grid layout. You can read more about centering in CSS here π.
After that, use
margin: 0.938rem
ormargin: 15px
in the.card
selector to add some space for the container card and the screen edge on mobile devices.
I hope you find it useful! π Above all, the solution you submitted is great!
Happy coding!
Marked as helpful0 - Use semantic elements such as
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