There are some important issues in this that need refactoring.
- It's great you've included a main landmark. But the attribution belongs in a
footer
not main. Make sure you update your link in the footer too, so it goes to your github or frontend mentor profile. - The image is the most important content on this whole challenge. It's definitely not a decorative image so must have alt text that says what it is (QR code) and where it goes (to FrontendMentor.io).
- This is a card component being built in isolation. But when we build components we have to think about how they will be used on the end website. This kind of card would never act as the title for a whole page, so it should not have a h1. Use a h2 instead. 4.Get into the habit of including a full modern css reset at the start of the styles in every project. Andy Bell or Josh Comeau both have good ones you can look up and use. That will set sensible defaults for cross browser styling.
- Your solution is broken when viewed on my phone, especially in landscape orientation because you have set the html, body and main height all to 100%. Remove this. To center the component on the screen all this needs is a min-height 100svh on the way, and flex column properties for the centering.
- Font size must be in rem not px.
- The card should not have an explicit width, especially not in px. This is an important principle to understand. When you set width it is fixed and removes all options for the browser to be able to make adjustments when it needs to. Instead, set a max-width in rem. This allows the card to shrink narrower if it needs to, like when viewed on a smaller screen. And using rem means the layout will scale correctly for all users including those who have a different text size.
- To ensure the component can't hit screen edges you can give a wrapping element padding (like the body).
- It looks like you have double padding at the end of the card. I recommend you onle set padding-inline on the content or use an alternative method if you want to limit its width within the card (eg margin-inline auto and a max width in rem or ch units).
There may be a couple of other things I'm not sure when the css is so hard to read minified.
Marked as helpful
@emzzz56
Posted
@grace-snow Thanks, for your review. I've refactored the code to meet your suggestions. Only one thing I didn't refactor which is the h1 tag; if I make it h2 or remove it, it won't pass the accessibility test on frontendmentor.io But for sure I agree with you in a real project scenario it shouldn't be h1. Thank you
@emzzz56 I'm a senior accessibility consultant so an confidently tell you it will pass but there will be a warning about the missing h1. But it is absolutely fine.
If you really want no warnings you can add a visually-hidden (otherwise known as "sr-only") h1 above the component saying something like "QR component demo" or similar.
Marked as helpful