# Link Preview Card

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

- Category: [CSS Cards](https://copy-css.com/category/cards)
- Tags: link preview, open graph, og image, embed, unfurl, url card
- Live preview: https://copy-css.com/snippets/link-preview-card
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```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

```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;
}
```

## Notes

- 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.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
