Design comparison
Solution retrospective
I'm still very new to html and css, only 1 month in, so I'll appreciate any advice on how to improve my skills! :)
Community feedback
- @Islandstone89Posted 9 months ago
HTML:
-
Do not remove the
<main>
, it is essential to have. And you have the card as.container
, which is perfectly fine. -
The image has meaning, so it must have proper alt text. Write something short and descriptive, without including words like "image" or "photo". Screen readers start announcing images with "image", so an alt text of "image of qr code" would be read like this: "image, image of qr code". The alt text must also say where it leads(frontendmentor.io).
-
.attribution
should be a<footer>
, and its text must be wrapped in a<p>
.
CSS:
-
Performance-wise, it's better to link fonts in the
<head>
of the HTML than using@import
. -
It's good practice to include a CSS Reset at the top.
-
Add around
1rem
ofpadding
on thebody
, so the card doesn't touch the edges on small screens. -
You don't need to set anything on
html
, so I would remove that selector. -
Remove all of the
position
properties, they are not meant to be used for layout. -
To center the card horizontally and vertically, use Flexbox on the body:
display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 100svh;
-
Move
background-color
andborder-radius
frommain
to.container
. Remove the width and height inpx
- you rarely want to set fixed dimensions, so this is something to keep in mind. -
Add a
max-width
of around20rem
on the card, to prevent it from getting too wide on larger screens. -
font-size
must never be in px. This is bad for accessibility, as it prevents the font size from scaling with the user's default setting in the browser. Use rem instead. -
Since all of the text should be centered, you only need to set
text-align: center
on the body, and remove it elsewhere. The children will inherit the value. -
Paragraphs have a default value of
font-weight: 400
, so there is no need to declare it. -
On the image, add
display: block
. Removeheight: auto
, as that is the default value. -
As the design doesn't change, there is no need for any media queries. When you do need them, they should be in rem, not px. Also, it is common practice to do mobile styles first and use media queries for larger screens.
Hope this helps :)
Marked as helpful1@dpiskovPosted 9 months ago@Islandstone89 Wow, that's a lot of useful information, thank you! I appreciate it a lot! I'll take my time soaking this information up and try hard to understand it! :)
1 -
- @Esesosa-maxPosted 9 months ago
Great Attempt, Approach Could be better (70 /100)
- Great Design, pretty much pixel-perfect
- Do not use a
<main>
tag to make a card because it is not semantically correct - Read HTML Semantics, it is okay to use multiple divs
- So next time, use a
<div>
and give a class of container or use another tag but do not a<main>
- Try using CSS variables it is nice!
- Do you know Flexbox? or CSS Grid?
- if not learn it, it will make centering much much easier
- Not Quite impressed, with the way you centered the
<main>
- Not Quite Responsive but the way you did it was smart
- Good Usage of Relative units like em or rem
Marked as helpful1@dpiskovPosted 9 months ago@Esesosa-max Thank you for the suggestions! About the parts you're not impressed about, could you give me an example of how I could've made and centered this card? Because I cannot quite understand everything you're telling me for now and I'd appreciate to see a better approach.
0
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