Blog card component with vanilla html/css

Solution retrospective
Figured out I could style text more efficiently by turning the "text presets" in the style guide provided in the figma design into individual classes and then just putting the class onto each text element that needs it.
Not much I would change, I think my way of going about things was pretty clean.
What challenges did you encounter, and how did you overcome them?Made things more DRY by setting up text preset classes instead of declaring text styles for each individual text element
What specific areas of your project would you like help with?None
Please log in to post a comment
Log in with GitHubCommunity feedback
- @gmagnenat
Hi,
Great job on your work so far! It looks pretty good.
Here are a few things I noticed.
-
Use
rem
formin-width
instead of pixels. Pixels are fixed units and don’t respect user preferences when they increase their browser’s default font size. Usingrem
ensures better accessibility. More on this here: Why you shouldn't use pixels for font-size. -
Heading structure: You correctly placed the
<h1>
first, which is great. However, since this is a blog preview card component that will appear in a grid with others, the title should likely be a lower heading level (e.g.,<h2>
or<h3>
). If you still want an<h1>
, consider making it visually hidden for screen reader users. -
The blog title needs to be a link. Since this is a preview, the heading should be wrapped in an
<a>
tag leading to the full blog post:<h3><a href="full-post-url">Blog Title</a></h3>
This improves navigation and usability.
-
Alt text improvement: Avoid using words like "image" or "picture" in
alt
attributes, as screen readers already announce them as images. If the image is purely decorative, leavealt=""
so it is skipped. Learn more here: How to write good alt text. -
Missing a modern CSS reset. Adding a reset at the start of your stylesheet improves consistency across browsers. Check out:
-
An active/hover state is missing. Adding styles for
:hover
,:focus
, and:active
states improves interactivity. To go further, you can make the whole card focusable and clickable by expanding the clickable area of the link using a pseudo-element. Here’s an example:.card a::after { content: ""; position: absolute; inset: 0; }
This is a great trick to learn for improving usability.
I can see that you already got some experience but I hope you find something useful in here to help you refactor your solution.
Have fun !
-
- @AmIKamil
Used border radius is bit different and space between author pic and name differs on first sight, but overall: very good job I am impressed with your code, it is very clean - i mean totally readable Comments are useful Very good step with declaring roots
I know that it was quite easy challenge, but I wish to write as good code as yours
(I've stalked you, looks like You're a pro :o followed :) hope to code something with you when I'll be ready ~AmIKamil)
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