Design comparison
Solution retrospective
Guys, what are your best practices for HTML and CSS? It would be of great help to a newbie.
Community feedback
- @andreimaierPosted almost 2 years ago
Hi there! π First off, great job on implementing the design!
Here are a few suggestions on how you can improve your code:
- try setting
display: flex
to yourbody
element
Syntax
body { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
This will align your
div.center
vertically.- add an
alt
description to yourimg.qr-code
For More info on when you should use
alt
attributes and when not to, check THIS π- try to use Semantic HTML as much as possible
- for example by replacing your
div.center
with themain
element - you can also add an
h1
heading, give it asr-only
class and hide it using something like this
- for example by replacing your
.sr-only { position: absolute; width: 1rem; height: 1rem; padding: 0; margin: -1rem; overflow: hidden; white-space: nowrap; border: 0; }
I'm also new, but I learned a lot from comments and looking at others' solutions.
If you have any questions or need further clarification, feel free to reach out to me. I'll do my best to help!
**Keep up the good work!!**ππ»
3 - try setting
- @LozzekPosted almost 2 years ago
I'm in the process of learning HTML and CSS as well and the best way is to literally keep doing projects. You may lose your mind on things you don't understand or if the code isn't working but trust just keep coding and looking things up and it will stick.
3 - @MelvinAguilarPosted almost 2 years ago
Hi there π. Good job on completing the challenge ! I have some feedback for you if you want to improve your code.
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.
- Since this component involves scanning the QR code, the image is not a decoration, so it must have an
alt
attribute. Thealt
attribute should explain its purpose. e.g.QR code to frontendmentor.io
CSS:
- 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.
- To center correctly you must set a height* to the "center" component and use
align-items: center;
.
I hope you find it useful! π Above all, the solution you submitted is great!
Happy coding!
2 - Use the
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