Market
Pricing
Sign inStart
Field GuideCSS and web
CSS and web

Transparent gradients in CSS: fades, overlays and scrims

A gradient that fades to nothing is one of the most useful tools in CSS. It also used to leave a grey smudge in the middle. Here is how transparency in gradients works now, and the patterns worth keeping.

GradientlyVerified Gradiently account·October 1, 2026·5 min read
Cover: Glazed Grove · GR·MYDN·TJ

The short version

  • To make a CSS gradient transparent, use a colour with zero alpha as one of the stops, such as transparent or rgb(124 58 237 / 0).
  • Modern browsers interpolate gradient colours with premultiplied alpha, so fading a colour to the transparent keyword no longer produces a grey band.
  • A background gradient can only fade the background; to fade an element's actual content, use mask-image with a gradient.
  • A scrim with several eased stops looks smoother than a two stop fade, which shows a visible edge where the darkening stops.
  • A radial gradient that is transparent in the centre and dark outside makes a spotlight that draws attention to one area.
On this page
Ways to write a transparent colourWhy fades used to turn greyFading content with mask-imageScrims: transparent gradients for textTransparent holes and spotlights

To make a CSS gradient transparent, give one of its stops a colour with zero alpha: linear-gradient(to bottom, #7c3aed, transparent) fades violet to nothing, letting whatever sits underneath show through. Use the same idea for fades at the end of text, dark scrims behind captions and coloured overlays on photos. For fading an element's content rather than its background, use mask-image with a gradient instead.

Ways to write a transparent colour

transparent

Means

Black at zero alpha

Use it when

Fading any colour out, in modern browsers
rgb(124 58 237 / 0)

Means

This violet at zero alpha

Use it when

Being explicit, or supporting very old browsers
rgb(124 58 237 / 0.4)

Means

This violet at 40 percent

Use it when

A tint that never fully disappears
#7c3aed66

Means

Eight digit hex, about 40 percent

Use it when

Design tools that export hex with alpha
color-mix(in srgb, var(--brand) 40%, transparent)

Means

A variable's colour at 40 percent

Use it when

Colours stored in custom properties
You writeMeansUse it when
transparentBlack at zero alphaFading any colour out, in modern browsers
rgb(124 58 237 / 0)This violet at zero alphaBeing explicit, or supporting very old browsers
rgb(124 58 237 / 0.4)This violet at 40 percentA tint that never fully disappears
#7c3aed66Eight digit hex, about 40 percentDesign tools that export hex with alpha
color-mix(in srgb, var(--brand) 40%, transparent)A variable's colour at 40 percentColours stored in custom properties
Five ways to say the same kind of thing. The color-mix() form is the only one that works on a colour you only know as a variable; see color-mix() in CSS.

Why fades used to turn grey

The keyword transparent is black with zero alpha. Early browsers blended the red, green and blue channels and the alpha channel separately, so a fade from white to transparent passed through half transparent grey on the way. That is why older tutorials insist on rgba(255, 255, 255, 0) instead.

The specification now requires premultiplied alpha: each colour is weighted by its opacity before blending, so a fully transparent stop contributes no colour at all. Every current browser does this. Writing the matching colour at zero alpha is still a harmless habit, and it keeps you safe in email clients and old WebViews.

Old behaviour

  • White to transparent dips through grey
  • Colour channels blended without regard to opacity
  • Workaround: repeat the colour at zero alpha

Current browsers

  • White to transparent stays white as it fades
  • Premultiplied alpha, as the specification requires
  • Either form works; the explicit one is more portable
Three fades shown over this page's own background, which is exactly what they do in your layout. Stack fades like these over a base colour to build soft, layered backgrounds.

Where the fade ends matters as much as its colours. A stop at 70 percent finishes the fade early and leaves the rest of the box fully clear, which is ideal for a tint that should only touch one edge. Two stops at the same position make a hard cut from colour to nothing, useful for half filled bars and split backgrounds. Stop positions are explained in CSS linear gradients.

Fading content with mask-image

A background gradient sits behind the content, so it cannot fade text, images or a scrolling list. A mask can. With mask-image, opaque parts of the gradient keep the element visible and transparent parts hide it. The colour of the mask doesn't matter, only its alpha.

css
/* Fade the last lines of a teaser paragraph */
.teaser {
  max-height: 9rem;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

/* Soft edges on a horizontally scrolling row */
.carousel {
  overflow-x: auto;
  mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}

/* Fade a photo into the page on any background colour */
.hero-photo {
  mask-image: linear-gradient(to bottom, #000 50%, transparent 95%);
}
Masks fade whatever is there, on any page colour, light or dark. Unprefixed mask-image works in current browsers; add -webkit-mask-image for older Safari.

The old alternative was a white gradient laid over the content. It breaks the moment the page is not white, in dark mode for instance, and it blocks clicks unless you remember pointer-events: none. A mask has neither problem.

Scrims: transparent gradients for text

A scrim darkens part of an image so text on it reads, fading to fully transparent so the rest of the photo stays bright. A two stop fade works, but its straight ramp leaves a visible line where the darkening ends. More stops, spaced to ease out, hide that edge.

Eased scrim, seven stopslinear-gradient(to top, rgb(2 6 23 / 0.8) 0%, rgb(2 6 23 / 0.62) 15%, rgb(2 6 23 / 0.42) 30%, rgb(2 6 23 / 0.24) 48%, rgb(2 6 23 / 0.1) 66%, rgb(2 6 23 / 0.03) 82%, rgb(2 6 23 / 0) 100%)
Opacity falls quickly near the text and slowly near the top, which reads as natural shade instead of a band.
css
.card {
  background-image:
    linear-gradient(to top,
      rgb(2 6 23 / 0.8) 0%, rgb(2 6 23 / 0.62) 15%, rgb(2 6 23 / 0.42) 30%,
      rgb(2 6 23 / 0.24) 48%, rgb(2 6 23 / 0.1) 66%, rgb(2 6 23 / 0.03) 82%,
      rgb(2 6 23 / 0) 100%),
    url("/images/coast.jpg");
  background-size: cover;
  color: #f8fafc;
}
The scrim is the first background layer, so it sits on top of the photo.

Tint the scrim with a deep version of the photo's colour rather than pure black and it will feel part of the picture. On a warm sunset photo, a deep brown such as rgb(41 20 8 / 0.75) sinks into the image, where black would look like a filter laid on top. Gradient overlays in CSS covers colour washes and blend modes, and text over images covers placement.

Transparent holes and spotlights

Flip the idea: transparent in the middle, dark outside. A radial gradient laid over a page or image leaves one area lit and quietly dims everything else, which suits onboarding tips, product close ups and slides.

css
.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at var(--x, 50%) var(--y, 40%),
    transparent 0 140px,
    rgb(2 6 23 / 0.72) 220px
  );
}
Set --x and --y from JavaScript to move the spotlight. The 80 pixel blend between the stops keeps the edge soft.
Just landed
NEW
The linen edit.
Six pieces, three colours
Gradiently · @gradiently

Without any shaping, words compete with the brightest part of the background.

Just landed
NEW
The linen edit.
Six pieces, three colours
Gradiently · @gradiently

The background quiets itself behind the words, the job a scrim does on a website.

For social posts and print, you rarely need to hand build scrims. In Gradiently the Mark itself makes room for your words, deepening or lifting the colours near the letters, with no overlay layer to tune for each size.

Design with a living gradient

Posts, stories, slides and banners in every size, with text that always reads.

Start designing, free

Questions people ask

How do I make a CSS gradient fade to transparent?

Use a zero alpha colour as the last stop: linear-gradient(#7c3aed, transparent) or, to be explicit, linear-gradient(#7c3aed, rgb(124 58 237 / 0)).

Why does my gradient to transparent look grey?

Older browsers blend without premultiplied alpha, so transparent (transparent black) greys the middle. Fade to your colour at zero alpha instead.

How do I fade out text or an image with CSS?

Use mask-image with a gradient, such as mask-image: linear-gradient(#000 60%, transparent). The element fades on any background colour.

What is a scrim in CSS?

A gradient that darkens part of an image behind text and fades to transparent elsewhere, so the text reads and the image stays bright.

Can a CSS gradient have a transparent hole?

Yes. A radial gradient that is transparent at the centre and dark further out leaves a clear spotlight over whatever sits beneath.

Share this guide

Written by GradientlyVerified Gradiently account

The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.

See our profile

On this page

Ways to write a transparent colourWhy fades used to turn greyFading content with mask-imageScrims: transparent gradients for textTransparent holes and spotlights

Share this guide

Next in CSS and web

Gradient overlay CSS: tint and darken images properly

Keep reading

All CSS and web guides
CSS and web

Gradient overlay CSS: tint and darken images properly

5 min read

Putting a gradient over a photo takes one extra line of CSS. Choosing the right one of three methods decides whether the image loads fast, the overlay can animate, and the words on top stay readable.

Gradients

Gradient overlays: tint photos without hiding them

6 min read

A good overlay changes the mood of a photo and gives your words somewhere to stand, while the picture still shows through. A bad one turns every image into the same murky rectangle. Here is how to tell them apart.

Type and text

Text over image: seven ways to keep words readable

5 min read

A photo that looks great on its own can swallow any headline you put on it. These seven techniques keep the words readable without hiding the picture behind a box.

Find the look that’s only yours.

Every Mark is a living background with one owner. Try an unclaimed Mark, and claim yours when it feels right.

Start designing

Check a certificate

Type a certificate number or a Mark’s code to see who owns it.

Works with ChatGPT and Claude

Ask your AI for a design. It makes it in your Mark, ready to edit.

ChatGPTClaude
How to connect

Product

  • Market
  • Explore
  • Pricing
  • Certificates

Learn

  • Field Guide
  • Help centre
  • What’s new

Developers

  • Overview
  • ChatGPT and Claude
  • API reference
  • API keys

Company

  • About
  • Contact us
  • Sign in

Legal

  • Terms
  • Privacy
  • Refunds
  • Mark protection
  • Cookies
  • All policies
Move through the letters. Each one wears a real Mark.Touch a letter to see its Mark.One name. Ten Marks inside it.
© 2026 Gradiently