Curated gradients · Text

Accessible gradients CSS gradients that carry text

Eleven gradients for banners, cards and notices, with the text color each one carries. Every point of every gradient is measured against its text, in the sRGB a browser falls back to and in the OKLab it is shipped in, so the number given is the worst a reader can meet.

Gradients
11
Text anywhere
8
At AAA
7
Traps, fixed
3
Spaces compared
3

Try one

Measured at every point

Choose a gradient, the space it is blended in and the size of the text. The chart under the banner is the contrast at each point along the gradient; the shaded stretches fail.

The controls need JavaScript. Without it the banner shows Indigo to violet, blended in OKLab, measured for body text.

Spring sale ends Sunday

Every plan is 40% off when you pay for a year.

See the plans
Contrast with the text along the gradient line, start to end
Lowest contrast
7.10:1 at 99% of the line
Passes along
100% of the line
Verdict
Passes everywhere

The measure is the gradient as a browser paints it: blended in the space named, rounded to 8 bits, sampled at least twice a pixel along a 1200 by 400 banner. Body text needs 4.5:1 and large text 3:1, under WCAG 1.4.3.

The traps

Three that look as if they should

Each fails for a different reason: a stop that is too light, a blend that dims, and a space that lightens. Each card shows the measurement and a fix that passes in both spaces.

  • Navy to amber

    Text on one side
    As designedsRGB2.14:1OKLab2.14:1OKLCH2.14:1

    What goes wrong White text passes on the left 49.5% of the line, then drops to 2.14:1 at the amber end. No space helps: the amber stop itself is too light.

    Fixed

    Summer festival tickets

    On sale now, from the box office or online.

    Buy tickets

    The fix Keep the text on the passing side: over the left 49% of the banner the worst point is 4.53:1, so the text column here is at most 45% wide. Or lay 33% black over the whole gradient, or move the amber stop to #A66900.

    CSS
    .banner {
      /* sRGB, for browsers that cannot read an interpolation space */
      background: linear-gradient(to right, #1E3A8A, #F59E0B);
      background: linear-gradient(to right in oklab, #1E3A8A, #F59E0B);
      color: #FFFFFF;
    }
    .banner .banner__text {
      max-width: 45%; /* white text passes on the left 49% */
    }
  • Pink to blue

    Needs a fix
    As designedsRGB4.15:1OKLab4.81:1OKLCH4.75:1

    What goes wrong Both ends pass, at 5.02:1 and 4.82:1, but the sRGB blend dims the middle to 4.15:1 at 49%. In OKLab it holds 4.81:1, yet a browser that cannot read in oklab shows the sRGB version.

    Fixed

    Launch week

    Five new tools, one a day.

    See what's new

    The fix Lay 5% white over the gradient: the worst point in either space becomes 4.52:1. Or lighten the stops to #F14D9E and #438AFF.

    CSS
    .banner {
      /* sRGB, for browsers that cannot read an interpolation space */
      background: linear-gradient(rgb(255 255 255 / 5%), rgb(255 255 255 / 5%)), linear-gradient(to right, #EC4899, #3B82F6);
      background: linear-gradient(rgb(255 255 255 / 5%), rgb(255 255 255 / 5%)), linear-gradient(to right in oklab, #EC4899, #3B82F6);
      color: #111827;
    }
  • Green to magenta

    Needs a fix
    As designedsRGB3.29:1OKLab3.28:1OKLCH2.99:1

    What goes wrong Here OKLab is the worse space: its middle turns lighter, and white text passes on only 10.8% of the line, against 73.9% in sRGB. In OKLCH the hue takes the short way round, through teal, and the lowest point falls to 2.99:1.

    Fixed

    Spring collection

    Fresh colors for the new season.

    Browse

    The fix Lay 17% black over the gradient: the worst point in either space becomes 4.53:1. Or darken the green stop to #00883A.

    CSS
    .banner {
      /* sRGB, for browsers that cannot read an interpolation space */
      background: linear-gradient(rgb(0 0 0 / 17%), rgb(0 0 0 / 17%)), linear-gradient(to right, #16A34A, #C026D3);
      background: linear-gradient(rgb(0 0 0 / 17%), rgb(0 0 0 / 17%)), linear-gradient(to right in oklab, #16A34A, #C026D3);
      color: #FFFFFF;
    }

Interpolation

The space can move the worst point

The same stops, blended in sRGB, OKLab and OKLCH, measured against the same text. Where they disagree by 0.05 or more, the lowest is underlined.

The lowest contrast of each gradient, blended in each space
GradientsRGBOKLabOKLCHWorst a reader meets
Indigo to violet7.10:17.10:17.10:17.10:1 sRGB
Ember7.30:17.30:17.29:17.30:1 sRGB
Forest7.07:17.07:17.07:17.07:1 OKLab
Ocean5.35:15.35:15.35:15.35:1 sRGB
Auric night7.18:17.18:17.18:17.18:1 sRGB
Dawn12.56:112.56:112.56:112.56:1 sRGB
Mist14.60:114.60:114.60:114.60:1 sRGB
Butter to lilac9.40:19.40:19.41:19.40:1 sRGB
Navy to amber2.14:12.14:12.14:12.14:1 OKLab
Pink to blue4.15:14.81:14.75:14.15:1 sRGB
Green to magenta3.29:13.28:12.99:13.28:1 OKLab
  • For most gradients the space hardly matters. When both stops are dark, or both light, every space blends them to colors of about the same contrast: 9 of these 11 move by less than 0.05.
  • When the stops differ in hue and lightness, it decides. sRGB dims the middle of Pink to blue; OKLab and OKLCH lighten the middle of Green to magenta. Neither space is always the safer: measure the one you ship.
  • Measure the fallback too. A browser that cannot read an interpolation space drops the whole declaration, so ship the sRGB version first and check both.

How each space blends, with the same two stops side by side, is in the gradient interpolation recipe.

Use it well

Where text can go

WCAG 1.4.3 measures text against what is behind it. On a gradient that is many colors, so the one that counts is the worst one under the text.

  1. Measure the worst point, not the ends: a light middle, or a blend that dims, is where text fails.
  2. Measure the stretch the text covers: the gradient line runs between the box's corners, and the text's corners mark the part it sits on.
  3. Measure what each reader gets: the sRGB fallback as well as the space you ship.
  4. When one side fails, keep the text on the other, or lay an even layer over the whole gradient; it moves every point the same way.
  5. Gradient-filled text is measured the other way round: every point of the gradient against the page behind it.

Code

Export the gradients

The eight as CSS classes, or as a JSON list with each one's worst contrast.

Rename the classes to fit your system.

CSS classes

.gradient-indigo-violet {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(135deg, #312E81, #6D28D9);
  background: linear-gradient(135deg in oklab, #312E81, #6D28D9);
  color: #FFFFFF;
}

.gradient-ember {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(to right, #9A3412, #9F1239);
  background: linear-gradient(to right in oklab, #9A3412, #9F1239);
  color: #FFFFFF;
}

.gradient-forest {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(135deg, #14532D, #3F6212);
  background: linear-gradient(135deg in oklab, #14532D, #3F6212);
  color: #FFFFFF;
}

.gradient-ocean {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(to right, #1E3A8A, #0E7490);
  background: linear-gradient(to right in oklab, #1E3A8A, #0E7490);
  color: #FFFFFF;
}

.gradient-auric-night {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(135deg, #332700, #6B5500);
  background: linear-gradient(135deg in oklab, #332700, #6B5500);
  color: #FFFFFF;
}

.gradient-dawn {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(to right, #FEF3C7, #FBCFE8);
  background: linear-gradient(to right in oklab, #FEF3C7, #FBCFE8);
  color: #1C1A16;
}

.gradient-mist {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(135deg, #E0F2FE, #EDE9FE);
  background: linear-gradient(135deg in oklab, #E0F2FE, #EDE9FE);
  color: #1C1A16;
}

.gradient-butter-lilac {
  /* sRGB, for browsers that cannot read an interpolation space */
  background: linear-gradient(to right, #FDE68A, #C4B5FD);
  background: linear-gradient(to right in oklab, #FDE68A, #C4B5FD);
  color: #1C1A16;
}

JSON list

[
  {
    "name": "Indigo to violet",
    "fallback": "linear-gradient(135deg, #312E81, #6D28D9)",
    "background": "linear-gradient(135deg in oklab, #312E81, #6D28D9)",
    "color": "#FFFFFF",
    "worstContrast": 7.1
  },
  {
    "name": "Ember",
    "fallback": "linear-gradient(to right, #9A3412, #9F1239)",
    "background": "linear-gradient(to right in oklab, #9A3412, #9F1239)",
    "color": "#FFFFFF",
    "worstContrast": 7.3
  },
  {
    "name": "Forest",
    "fallback": "linear-gradient(135deg, #14532D, #3F6212)",
    "background": "linear-gradient(135deg in oklab, #14532D, #3F6212)",
    "color": "#FFFFFF",
    "worstContrast": 7.07
  },
  {
    "name": "Ocean",
    "fallback": "linear-gradient(to right, #1E3A8A, #0E7490)",
    "background": "linear-gradient(to right in oklab, #1E3A8A, #0E7490)",
    "color": "#FFFFFF",
    "worstContrast": 5.35
  },
  {
    "name": "Auric night",
    "fallback": "linear-gradient(135deg, #332700, #6B5500)",
    "background": "linear-gradient(135deg in oklab, #332700, #6B5500)",
    "color": "#FFFFFF",
    "worstContrast": 7.18
  },
  {
    "name": "Dawn",
    "fallback": "linear-gradient(to right, #FEF3C7, #FBCFE8)",
    "background": "linear-gradient(to right in oklab, #FEF3C7, #FBCFE8)",
    "color": "#1C1A16",
    "worstContrast": 12.56
  },
  {
    "name": "Mist",
    "fallback": "linear-gradient(135deg, #E0F2FE, #EDE9FE)",
    "background": "linear-gradient(135deg in oklab, #E0F2FE, #EDE9FE)",
    "color": "#1C1A16",
    "worstContrast": 14.6
  },
  {
    "name": "Butter to lilac",
    "fallback": "linear-gradient(to right, #FDE68A, #C4B5FD)",
    "background": "linear-gradient(to right in oklab, #FDE68A, #C4B5FD)",
    "color": "#1C1A16",
    "worstContrast": 9.4
  }
]

The eight that carry text anywhere, each with its fallback and its text color. The traps are left out; their fixed CSS is on their cards.

Sources

Sources and method

The criteria, the CSS that paints the gradients, and the space they are shipped in.

The measuring is the gradient contrast checker's: stops resolved by CSS's rules, blends premultiplied by alpha, each color rounded to 8 bits as a browser paints it, and contrast as the WCAG 2 ratio, floored to two decimals. Node tests recompute every number on this page. Checked with axe and the keyboard in Chromium; not yet tested with a screen reader. Last reviewed on 14 October 2026.

Found a mistake? Write to us and we will correct it.