CSS Link Preview Card

A rich link preview like chat apps show for shared URLs, with a 1.91:1 image, domain, title and summary.

  • link preview
  • open graph
  • og image
  • embed
  • unfurl
  • url card
HTML
<a class="link-preview" href="#">
  <span class="link-preview-img" aria-hidden="true"></span>
  <span class="link-preview-body">
    <small>example.com</small>
    <strong>Ship faster with design tokens</strong>
    <span>A short guide to naming, theming and syncing tokens across code and design.</span>
  </span>
</a>
CSS
.link-preview {
  display: block;
  width: 260px;
  overflow: hidden;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  background: #fff;
  color: #18181b;
  font-family: system-ui, sans-serif;
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.link-preview:hover {
  border-color: #a1a1aa;
}

.link-preview:focus-visible {
  outline: 3px solid #7c3aed;
  outline-offset: 2px;
}

.link-preview-img {
  display: block;
  aspect-ratio: 1.91 / 1;
  background: linear-gradient(135deg, #c4b5fd, #7c3aed 60%, #4c1d95);
  /* Replace with: background: url(your-og-image.jpg) center / cover; */
}

.link-preview-body {
  display: grid;
  gap: 3px;
  padding: 10px 14px 12px;
}

.link-preview small {
  color: #71717a;
  font-size: 12px;
}

.link-preview strong {
  font-size: 14px;
  line-height: 1.3;
}

.link-preview-body span {
  display: -webkit-box;
  overflow: hidden;
  color: #52525b;
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

About this CSS Link Preview Card

This CSS Link Preview Card is 54 lines of pure CSS (1.0 KB) with no JavaScript and no dependencies. It uses transitions, linear gradients, CSS Grid and aspect-ratio. 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:

  • #e4e4e7
  • #fff
  • #18181b
  • #a1a1aa
  • #7c3aed
  • #c4b5fd
  • #4c1d95
  • #71717a
  • #52525b

How to use this link preview 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 .link-preview 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