Submitted over 1 year ago
Simple Responsive QR code component
@NourElDinEmad
Design comparison
SolutionDesign
Solution retrospective
Do you have any questions about best practices?
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there π. Congratulations on successfully completing the challenge! π
- I have other recommendations regarding your code that I believe will be of great interest to you.
CSS π¨:
- Let me explain, How you can easily center the component for better layout without usage of
absolute
positioning.
- We don't need to use
absolute
to center the component both horizontally & vertically. Because using `absolute' will not dynamical centers our component at all states
- To properly center the component in the page, you should use
Flexbox
orGrid
layout. You can read more about centering in CSS here π.
- For this demonstration we use css
Grid
to center the component
body { min-height: 100vh; display: grid; place-items: center; }
- Now remove these styles, after removing you can able to see the changes
.card { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); margin: auto; }
- Now your component has been properly centered
HTML π·οΈ:
- This solution lacks semantic markup, which causes lacking of landmark for a webpage and allows accessibility issues to screen readers, due to accessibility errors our website may not reach its intended audience, face legal consequences, and have poor search engine rankings, highlighting the importance of ensuring accessibility and avoiding errors.
- What is meant by landmark ?, They used to define major sections of your page instead of relying on generic elements like
<div>
or<span>
. They are use to provide a more precise detail of the structure of our webpage to the browser or screen readers
- For example:
- The
<main>
element should include all content directly related to the page's main idea, so there should only be one per page - The
<footer>
typically contains information about the author of the section, copyright data or links to related documents.
- The
- So resolve the issue by replacing the
<div class="card">
element with the semantic element<main>
along with<div class="attribution">
with<footer>
element in yourindex.html
file to improve accessibility and organization of your page
.
I hope you find this helpful π Above all, the solution you submitted is great !
Happy coding!
Marked as helpful0 - @talissoncostaPosted over 1 year ago
Hello @NourElDinEmad
First of all, congrats for your solution. I've got some tips for your:
- Use semantic tags. You should use the tag
main
to wrap up your solution. - Use a
h1
instead of ah3
. It will help screen readers to understand where is the title. - Avoid using
tag
name on your styles. Although it works, it is not a good practice. Useclasses
orids
instead. - Border-radius does not seem to be accurate, you are using
10px
for the img and the card. Nevertheless, on the designs the border radius for the image seems to be less than it is on the card. - Try to explore
flexbox
in your next projects. As soon as you get used to it you will see how it is helpful, you will write a better code, more concise and easier to manage.
I hope it helps Happy coding! :D
Marked as helpful0 - Use semantic tags. You should use the tag
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