Market
Pricing
Sign inStart
Field GuideCSS and web
CSS and web

Gradient overlay CSS: tint and darken images properly

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.

GradientlyVerified Gradiently account·October 1, 2026·5 min read
Cover: Clover Furnace · GR·HCFS·5E

The short version

  • The quickest gradient overlay in CSS is a second background layer: list the gradient before url() in background-image so it sits on top.
  • For an img element, put the gradient on a ::before or ::after pseudo-element of a positioned wrapper.
  • background-blend-mode and mix-blend-mode turn a gradient overlay into a colour wash that tints the image rather than covering it.
  • Hero images set as CSS backgrounds are discovered later than img elements, so an img with an overlay usually loads faster above the fold.
  • Overlays meant to carry text should be darkest behind the words and transparent elsewhere, not an even dark film over the whole photo.
On this page
Method 1: a layered backgroundMethod 2: a pseudo-element over an imgMethod 3: blend modes for colour washesOverlays that keep text readableOverlays without the guesswork

The simplest gradient overlay CSS is a layered background: background-image: linear-gradient(rgb(2 6 23 / 0.6), rgb(2 6 23 / 0)), url(photo.jpg). Layers listed first are drawn on top, so the gradient sits over the photo. When the image is an <img> element, put the gradient on a pseudo-element instead, and when you want the colour to tint the photo rather than cover it, add a blend mode. Each method suits a different job.

Method 1: a layered background

background-image accepts a comma separated list. The first value is the top layer. Gradients and images mix freely, and each layer can have its own size and position if you list those properties in the same order. This is the right choice for decorative images where no alt text is needed.

css
.banner {
  background-color: #0f172a; /* shows until the photo loads */
  background-image:
    linear-gradient(to right, rgb(15 23 42 / 0.9) 0%, rgb(15 23 42 / 0.6) 40%, rgb(15 23 42 / 0) 70%),
    url("/images/workshop.jpg");
  background-size: cover;
  background-position: center;
  color: #f8fafc;
}
A dark panel on the left for copy, clearing by 70 percent so the right of the photo stays bright. The fallback colour matches the overlay, so text reads even before the image arrives.
Four overlay presets, shown here over the page. Drop any of them in front of url() in your own background-image.

The top and bottom bars suit galleries where a title sits at the top and a credit at the bottom. The vignette draws the eye inward without carrying text. The brand tint is a strong look for team pages and event banners; gradient overlays covers when each feels right from a design point of view.

Method 2: a pseudo-element over an img

Content images belong in <img> elements: they get alt text, responsive srcset, lazy loading and early discovery by the browser. A background gradient cannot sit over an <img>, so wrap it and put the gradient on the wrapper's pseudo-element.

html
<figure class="overlay">
  <img src="/images/harbour.jpg" alt="Fishing boats moored in a small harbour at dusk"
       width="1920" height="1080" fetchpriority="high">
  <figcaption>Harbour Days, 14 to 16 June</figcaption>
</figure>
A real image element with real alt text. The caption will sit on the overlay.
css
.overlay {
  position: relative;
  margin: 0;
  isolation: isolate;
}

.overlay img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(2 6 23 / 0.75), rgb(2 6 23 / 0) 60%);
  pointer-events: none;
  transition: opacity 250ms ease-out;
}

.overlay figcaption {
  position: absolute;
  inset: auto 1.5rem 1.5rem;
  z-index: 1;
  color: #f8fafc;
}

.overlay:hover::after { opacity: 0.6; }
isolation: isolate keeps the overlay's stacking inside the figure. The overlay can fade on hover because it is its own layer.

Background layer

  • One element, one declaration
  • No alt text, so decorative images only
  • Found late by the browser, which can slow a hero
  • Overlay cannot fade without animating the whole background

img plus pseudo-element

  • A wrapper and a few more lines
  • Proper alt text and responsive srcset
  • Discovered early; fetchpriority="high" helps the main image
  • Overlay opacity transitions cheaply

For a hero image that is the largest thing on screen, the second method usually wins on loading speed. Optimising images for the web explains why the browser finds <img> elements sooner than CSS backgrounds.

Method 3: blend modes for colour washes

A plain overlay sits on the photo like tinted glass. A blend mode mixes the gradient into the photo's own light and dark, which looks more like the photo was shot in that colour. Use background-blend-mode for layered backgrounds and mix-blend-mode on a pseudo-element over an <img>.

multiply

What it does

Darkens; white areas take the gradient's colour

Good overlay for

Rich, moody tints on bright photos
screenLightens; black areas take the colour

Good overlay for

Airy, faded looks on dark photos
overlay

What it does

Boosts contrast and pushes colour into midtones

Good overlay for

Punchy brand colour on portraits
colorKeeps the photo's light, replaces its colour

Good overlay for

Duotone style washes from a two colour gradient
soft-light

What it does

A gentle version of overlay

Good overlay for

Subtle warmth or coolness
Blend modeWhat it doesGood overlay for
multiplyDarkens; white areas take the gradient's colourRich, moody tints on bright photos
screenLightens; black areas take the colourAiry, faded looks on dark photos
overlayBoosts contrast and pushes colour into midtonesPunchy brand colour on portraits
colorKeeps the photo's light, replaces its colourDuotone style washes from a two colour gradient
soft-lightA gentle version of overlaySubtle warmth or coolness
The five modes worth knowing. color with a two colour gradient is the quickest web duotone.
css
/* Duotone wash on a layered background */
.duotone {
  background-image:
    linear-gradient(135deg, #1e1b4b 0%, #f472b6 100%),
    url("/images/portrait.jpg");
  background-size: cover;
  background-blend-mode: color;
}

/* The same idea over an img element */
.overlay--wash::after {
  background: linear-gradient(135deg, #1e1b4b, #f472b6);
  mix-blend-mode: color;
}
background-blend-mode blends layers of one element. mix-blend-mode blends an element with whatever is behind it, here the photo.

The full technique, including how to pick the two colours, is in the duotone effect.

Overlays that keep text readable

The most common mistake is an even dark film over the entire photo, say 50 percent black. It dulls the image everywhere and still may not be dark enough behind the words. Shape the overlay instead: darkest under the text, clear where the photo matters.

  1. 1

    Decide where the words go

    Bottom left for captions, left third for hero copy, centre for a single line.

  2. 2

    Point the gradient at them

    Use to top for bottom text, to right for left text, or a radial centred on the words.

  3. 3

    Stop early

    Fade to fully transparent by 60 to 70 percent so most of the photo stays untouched.

  4. 4

    Check the worst case

    Measure contrast where the photo is brightest behind a letter. Colour contrast and accessibility lists the ratios.

Eased scrims with many stops look smoother than a two stop fade; the method is in transparent gradients in CSS.

Overlays without the guesswork

On a website you tune each overlay by hand. For social posts, banners and slides, Gradiently skips the step: a Mark knows where your words are and deepens or lifts its own colours behind them, and photos can be tinted in the Mark's colours as mono, duotone or a wash, and with Pro the design resizes to every format in one step, with no overlay to rework.

14 to 16 June
Harbour Days.
Music, food and boats on the quay
Gradiently · @gradiently

An event banner at website hero size, with the background calming behind the words instead of a hand tuned overlay.

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 put a gradient over a background image in CSS?

List the gradient before the image in background-image: linear-gradient(rgb(0 0 0 / 0.5), transparent), url(photo.jpg). The first layer is drawn on top.

How do I add a gradient overlay to an img element?

Wrap the image in a positioned element and put the gradient on its ::after pseudo-element with position: absolute and inset: 0.

What is the difference between background-blend-mode and mix-blend-mode?

background-blend-mode blends the background layers of one element. mix-blend-mode blends a whole element with what is behind it.

How dark should an image overlay be for text?

Dark enough that the text passes contrast checks at the brightest point behind it. Shape the gradient so it is darkest there and clear elsewhere.

Can I animate a gradient overlay on hover?

Yes. Put the overlay on a pseudo-element and transition its opacity, which is cheaper than animating the background itself.

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

Method 1: a layered backgroundMethod 2: a pseudo-element over an imgMethod 3: blend modes for colour washesOverlays that keep text readableOverlays without the guesswork

Share this guide

Next in CSS and web

CSS gradient hover effect: four ways to animate it

Keep reading

All CSS and web guides
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.

CSS and web

Transparent gradients in CSS: fades, overlays and scrims

5 min read

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.

Gradients

The duotone effect: make any photo on-brand in two colours

5 min read

Duotone turns any photo into two colours of your choosing: one for the shadows, one for the light. It is the fastest way to make mismatched pictures look like one brand.

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