Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

My First HTML/CSS Exercise

Pythonicβ€’ 20

@pyth0n1c0

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Guys, what are your best practices for HTML and CSS? It would be of great help to a newbie.

Community feedback

andreimaierβ€’ 180

@andreimaier

Posted

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 your body 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 your img.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 the main element
    • you can also add an h1 heading, give it a sr-only class and hide it using something like this
.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
Kevin Koziolβ€’ 390

@Lozzek

Posted

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

@MelvinAguilar

Posted

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. The alt 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 or rem. 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

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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