# Image Scrim Gradient

> An eased dark gradient over a photo so white caption text stays readable without a hard edge.

- Category: [CSS Gradients & Patterns](https://copy-css.com/category/gradients)
- Tags: overlay, text on image, readable, caption, eased
- Live preview: https://copy-css.com/snippets/image-scrim-gradient
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<figure class="scrim-card">
  <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='0' y2='1'%3E%3Cstop stop-color='%23fb923c'/%3E%3Cstop offset='1' stop-color='%23fde68a'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='400' height='300' fill='url(%23g)'/%3E%3Ccircle cx='290' cy='110' r='36' fill='%23fff7ed'/%3E%3Cpath d='M0 200 110 110l80 70 70-50 140 100v170H0z' fill='%237c3aed'/%3E%3Cpath d='M0 240 90 180l120 80 70-40 120 70v110H0z' fill='%233b0764'/%3E%3C/svg%3E" alt="Purple mountains at sunset">
  <figcaption>
    <strong>Sunset ridge trail</strong>
    <span>12 km · Moderate</span>
  </figcaption>
</figure>
```

## CSS

```css
.scrim-card {
  position: relative;
  width: min(100%, 280px);
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
  font: 14px/1.3 system-ui, sans-serif;
}

.scrim-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

/* Many stops ease the fade, so there is no visible line where it starts */
.scrim-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    #000000b3 0%,
    #000000a1 14%,
    #00000080 28%,
    #00000059 42%,
    #00000033 56%,
    #00000014 70%,
    #0000 85%
  );
}

.scrim-card figcaption {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  display: grid;
  gap: 2px;
  padding: 16px;
  color: #fff;
}

.scrim-card strong {
  font-size: 18px;
}

.scrim-card span {
  color: #e5e7eb;
}
```

## Notes

- This CSS Image Scrim Gradient is 50 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses linear gradients, CSS Grid and aspect-ratio.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
