Design comparison
Solution retrospective
I am happy to start working with HTML and CSS.
What challenges did you encounter, and how did you overcome them?I had a bit of trouble placing some elements, but I went back to some of my personal notes.
What specific areas of your project would you like help with?I would like to know if the CSS code I used to place elements is as optimized as possible.
Community feedback
- @Islandstone89Posted 4 days ago
HTML:
-
I would remove
<figure>
, as it is not needed. -
The alt text must also say where it leads(the frontendmentor website). A good alt text would be "QR code leading to the Frontend Mentor website."
-
I would change the heading to a
<h2>
- a page should only have one<h1>
, reserved for the main heading. As this is a card heading, it would likely not be the main heading on a page with several components. -
Wrap the footer text in a
<p>
.
CSS:
-
Including a CSS Reset at the top is good practice.
-
I recommend adding a bit of
padding
, for example16px
, on thebody
, to ensure the card doesn't touch the edges on small screens. -
Move
font-family
tobody
, it's not common to set styles onhtml
. -
Remove
font-size: 62.5%
, as changing the font size is not recommended. -
Remove
font-size
on the heading and the paragraph, as their default values are suitable. -
Move the styles on
main
tobody
, this way you can also center the<footer>
, since it is a direct children ofbody
. -
On the
body
, removeheight: 100%
and changeheight
tomin-height: 100svh
- this way, the content will not get cut off if it grows beneath the viewport. Addflex-direction: column
so thefooter
sit underneath themain
instead of besides it. Also, addgap: 20px
, to have some space between thefooter
and themain
. -
Remove all widths and heights.
-
Add a
max-width
of around20rem
on the card, to prevent it from getting too wide on larger screens. -
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. -
I would change the padding on the card to
16px 16px 24px 16px;
. -
On the image, add
display: block
,height: auto
andmax-width: 100%
- the max-width prevents it from overflowing its container. Without this, an image would overflow if its intrinsic size is wider than the container.max-width: 100%
makes the image shrink to fit inside its container. -
Remove
positon: fixed
on thefooter
, as well asmargin
on.attribution
. -
Instead of nested selectors like
.content__text p
, it's recommended to apply a class to an element, and use that as a selector.
Marked as helpful1 -
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