
Design comparison
Solution retrospective
I used clamp() for font sizes and a media query to ensure the card adapts well to smaller screens. This makes the design scalable and user-friendly on mobile devices.
Use CSS Variables for Consistency: I’d centralize more values (like the border-radius, box-shadow, or gap sizes) into :root variables to ensure easier adjustments.
Improve Code Modularity: Refactor some reusable styles (like display: flex with common align-items and gap) into utility classes or use a preprocessor like Sass for better maintainability.
Community feedback
- @AmyH-goosePosted 3 months ago
I believe you did remarkably. As a beginner too, I've learned a few things from looking at your code (thanks!). I think to make sure that people who choose to have different font sizes on their browser have a better experience, use rem or em instead of hard px so that it adjusts along with their setting choices.
Marked as helpful1 - P@Islandstone89Posted 3 months ago
HTML:
-
I would wrap the date in a
<time>
tag:<p class="date">Published <time datetime="2023-12-21">21 Dec 2023</time></p>
. -
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. -
As this is a blog card, the heading should have a link inside.
-
A better alt text for the profile image would be something like "Headshot of Greg Hooper".
-
Wrap the footer text in a
<p>
.
CSS:
-
Make a habit of always including a proper CSS Reset at the top of the stylesheet.
-
I recommend adding a bit of
padding
, for example16px
, on thebody
, to ensure the card doesn't touch the edges on small screens. -
Remember to specify a fallback font:
font-family: 'Figtree', system-ui, sans-serif;
-
Add a
gap
of around20px
on thebody
, so the<footer>
doesn't squeeze up against the card. -
Remove the styles on
.main_container
, they are not needed. -
Remove
height: fit-content
on the card, it is not needed. -
Remove the
width
inpx
on the card. We rarely want to give a component a fixed size, as we need it to grow and shrink according to the screen size. -
We do want to limit the width of the card, so it doesn't get too wide on larger screens. To solve this issue, give the card a
max-width
of around20rem
. -
font-size
must never be in px. This is a big accessibility issue, as it prevents the font size from scaling with the user's default setting in the browser. Use rem instead. -
I don't think this challenge needs any media queries. When you do need them, they should be in
rem
orem
, notpx
. Also, it is common practice to do mobile styles first and use media queries for larger screens.
Marked as helpful0 -
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