CSS Trending Posts Card

A sidebar widget listing popular posts with large zero-padded numbers drawn by a CSS counter.

  • trending
  • popular posts
  • sidebar
  • numbered list
  • blog
  • counter
HTML
<section class="trending" aria-labelledby="trending-title">
  <h3 id="trending-title">Trending</h3>
  <ol>
    <li><a href="#">The case for boring CSS</a><span>4 min read</span></li>
    <li><a href="#">Grid or flexbox, a field guide</a><span>6 min read</span></li>
    <li><a href="#">Writing forms people finish</a><span>8 min read</span></li>
  </ol>
</section>
CSS
.trending {
  width: 260px;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  color: #1c1917;
  font-family: system-ui, sans-serif;
}

.trending h3 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trending ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: trending;
}

.trending li {
  display: grid;
  grid-template-columns: 38px 1fr;
  padding: 8px 0;
  border-top: 1px solid #f5f5f4;
  counter-increment: trending;
}

.trending li::before {
  content: counter(trending, decimal-leading-zero);
  grid-row: span 2;
  color: #eab308;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.trending a {
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}

.trending a:hover {
  text-decoration: underline;
}

.trending a:focus-visible {
  outline: 2px solid #ca8a04;
  outline-offset: 2px;
}

.trending span {
  color: #a8a29e;
  font-size: 12px;
}

About this CSS Trending Posts Card

This CSS Trending Posts Card is 61 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses CSS Grid and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #fff
  • #1c1917
  • #f5f5f4
  • #eab308
  • #ca8a04
  • #a8a29e

How to use this trending posts card

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .trending class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback