By · Updated

Blog Card CSS

Article Preview Cards With Cover Image, Category Tag and Author Line

No ratings yet

Layout

Colours

Content

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Blog Card Builder works

This blog card CSS builder writes a consistent card for every post. A blog index is a grid of cards, and every card needs the same parts: cover image, category, date, title, a short excerpt and who wrote it. Set the layout and styling, type in your own copy, and copy a card whose whole surface is a single accessible link.

Blog card CSS: the parts of a card

A post card is a summary that persuades someone to click. The generated markup puts the parts in reading order — image, metadata, title, excerpt, author — and wraps everything in one <a> so the entire card is clickable without any JavaScript or nested-link hacks.

One link, not several. The temptation is to link the image, the title and a "read more" button separately. That creates three tab stops per card for keyboard users and three identical announcements for screen readers. Wrapping the card in a single anchor gives one stop and one clear label — the heading text — while keeping the whole surface clickable. The link's default underline is removed on the card and color: inherit keeps text in the card colour.

Vertical or horizontal. Vertical cards stack image over text and belong in a grid of two or three columns; the width slider sets their maximum width. Horizontal cards put the image in a fixed-width left column and suit single-column lists, sidebars and "related posts" rows. The horizontal version includes a breakpoint that stacks it below 600px, because a 220px image next to 150px of text is not a layout anyone wants on a phone.

The image. The <img> has aspect-ratio: 16 / 9 and object-fit: cover, so covers of any proportion fill the slot without stretching and the card height is stable before the image loads. The preview paints a gradient where the photo would be. The alt is empty because the image is decorative here — the heading already says what the post is — and an empty alt stops screen readers reading a filename.

Metadata row. Category tag, date and read time sit on one line at reduced opacity. The tag is a pill in the accent colour so it reads as a label. Read time is optional but consistently increases click-through on long-form content because it sets expectations.

Clamped excerpt. The excerpt is limited to a set number of lines with -webkit-line-clamp, which every current browser supports despite the prefix. This keeps cards in a row the same height regardless of excerpt length. Three lines is the usual sweet spot; one line works for dense lists.

Author line pinned to the bottom. margin-top: auto on the author row pushes it to the bottom of the card body, so in a grid where cards stretch to equal height the author sits on the same baseline across the row. The avatar is initials on the accent colour; swap the span for an <img> with the same size if you have author photos.

Dates. Wrap the date in <time datetime="2026-09-14"> in production so it is machine readable. The generator keeps it as plain text so you can type any format.

FAQ

Should the whole blog card be a link?

Yes, when the card leads to one destination. Wrap it in a single <a> as the generated markup does. Block-level links have been valid HTML since HTML5. Avoid putting a second interactive element such as an author link inside; if you need one, take it out of the anchor and position it over the card with CSS.

How do I keep all cards in a row the same height?

Put them in a CSS grid or flex row — items stretch to the tallest by default — and clamp the excerpt so it cannot run long. The fixed image aspect ratio and the margin-top: auto on the author line take care of the rest, so titles of different lengths do not push the footer around.

Is -webkit-line-clamp safe to use?

Yes. Despite the prefix it is supported in Chrome, Edge, Firefox and Safari and is the only reliable way to truncate to multiple lines in CSS. It needs display: -webkit-box, -webkit-box-orient: vertical and overflow: hidden together, which the snippet includes. The standard line-clamp property is coming and browsers will alias it.

What image size should I use for blog card covers?

A 16:9 image at 800×450px is enough for a 380px card on a high-density screen and compresses to well under 100KB as WebP. Generate one card-sized version rather than serving the full article header image, and add loading="lazy" to cards below the fold.

How do I add a hover effect?

Add transition: transform 0.2s, box-shadow 0.2s to .post-card and a :hover rule with transform: translateY(-3px) and a soft shadow. Because the card is a link, the same rule can target :focus-visible so keyboard users see the same feedback. The Hover Card tool generates these variants.

See also: all UI Components tools, Layout & Spacing, Shadows & Motion, Shapes & SVG, Forms & Inputs, Colour.

Related tools