Most CSS gradient mistakes fall into a few families: the gradient does not show at all, it looks muddy or striped, text on top becomes hard to read, or it makes the page slow. Below are the eight CSS gradient mistakes we see most often while building the CSS gradient generator, each with the cause and the fix. If you are new to the syntax, start with the complete guide to CSS gradients.
1. Putting a gradient in background-color
Symptom: the declaration is ignored and the element stays plain.
Cause: a gradient is an image value, not a color. MDN describes it as “a special type of <image>” (MDN), so background-color: linear-gradient(...) is invalid and dropped.
Fix: use background-image or the background shorthand.
/* Wrong */
.box { background-color: linear-gradient(#f3dccf, #a34a28); }
/* Right */
.box { background-image: linear-gradient(#f3dccf, #a34a28); }
2. Forgetting a solid fallback color
Symptom: text is unreadable when the gradient fails to apply – for example when an unsupported color space makes the whole declaration invalid, or when a user stylesheet removes background images.
Fix: always set a background-color that gives readable text on its own, then layer the gradient on top. When you use a modern syntax such as in oklch, put a plain sRGB gradient first; the browser keeps the last declaration it understands.
.hero {
color: #f7f4ec;
background-color: #2a1f1a;
background-image: linear-gradient(160deg, #3a2b23, #2a1f1a);
background-image: linear-gradient(in oklch 160deg, #3a2b23, #2a1f1a);
}
3. Muddy, greyish midpoints
Symptom: a gradient between two bright colors – blue to yellow, say – goes dull or grey in the middle.
Cause: for compatibility, gradients between legacy colors (hex, rgb(), hsl(), named colors) are blended in sRGB; the CSS Color 4 changelog notes that interpolation between legacy sRGB colors is “(once again) in sRGB space, for compatibility” (W3C, CSS Color 4). A straight line through sRGB between distant hues passes through darker, less saturated colors.
Fix: choose a perceptual color space with in oklab, or in oklch to keep saturation by rotating the hue.
background-image: linear-gradient(in oklab to right, #1d4ed8, #facc15);
4. Banding on large, subtle gradients
Symptom: visible stripes in a soft gradient, especially across a full-width hero or on a dark background.
Cause: when two similar colors are stretched across many pixels, there are not enough distinct color values between them, so neighbouring pixels share the same value and form bands.
Fixes, from simplest to strongest:
- Increase the color difference a little, or shorten the distance the gradient covers.
- Add an intermediate stop in a perceptual space so lightness changes more evenly.
- Add subtle grain. A faint noise layer breaks the bands up (dithering). Our gradient generator has a grain control that adds an SVG noise layer and checks its paint cost.
.hero {
background-image:
url("noise.svg"), /* a tiny tiling noise texture at low opacity */
linear-gradient(in oklab 180deg, #3a2b23, #2a1f1a);
}
5. Fading to transparent and expecting grey
Symptom (in very old browsers): linear-gradient(red, transparent) shows a grey band.
Cause and current behaviour: transparent is transparent black. The CSS Images specification avoids the grey by interpolating “in premultiplied RGBA space”; it explains that without this “the center of the gradient would be a noticeably grayish color” (W3C, CSS Images 3). Current browsers follow it, so this is mostly a legacy concern.
Habit worth keeping: fade to the same color at zero alpha, which is correct everywhere and states your intent clearly.
background-image: linear-gradient(#a34a28, #a34a2800);
6. Checking text contrast against the average color
Symptom: a heading passes a contrast check on one side of the banner and fails on the other.
Cause: WCAG 2.2 Success Criterion 1.4.3 asks for at least 4.5:1 for normal text and 3:1 for large text, measured against the background the text is actually rendered over (W3C, Understanding 1.4.3). A gradient has many backgrounds.
Fix: measure against the gradient color that is closest in lightness to your text – usually one end – with the color contrast checker. If it fails, darken that end, add a translucent scrim behind the text, or move the text to the stronger side. Our gradient generator runs this check across the whole gradient for you.
7. Using a corner keyword when you meant a fixed angle
Symptom: the gradient looks right on a square card but tilts strangely on a wide banner.
Cause: to bottom right aims at the corner, so the real angle changes with the box’s aspect ratio; 135deg is the same on every box (MDN).
Fix: use a corner keyword only when the gradient must meet that corner; otherwise use an angle so cards of different sizes match.
8. Animating the gradient itself
Symptom: a moving “aurora” background stutters on phones and drains battery.
Cause: animating background-position, background-size or the gradient colors forces the browser to repaint the area on every frame. Guidance on web.dev recommends sticking to compositor-only properties – transform and opacity – noting that “today there are only two properties for which that is true” (web.dev).
Fix: put the gradient on a pseudo-element or child layer and move or fade that layer with transform and opacity, and switch the animation off for people who prefer reduced motion.
.aurora { position: relative; overflow: hidden; }
.aurora::before {
content: "";
position: absolute;
inset: -20%;
background-image: radial-gradient(40% 50% at 30% 40%, #e9b49688, transparent 70%);
animation: drift 16s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(10%, 6%, 0); } }
@media (prefers-reduced-motion: reduce) { .aurora::before { animation: none; } }
A loop that runs longer than five seconds alongside other content also needs a pause control to meet WCAG 2.2.2, so offer one or keep the movement short.
Avoiding CSS gradient mistakes: a checklist before you ship
- Gradient in
background-image, with a readablebackground-colorunderneath. - Modern color spaces (
in oklab/in oklch) behind an sRGB fallback. - No visible bands at full width on a large, dark screen.
- Text passes contrast at the weakest part of the gradient.
- Animations move a layer with
transformoropacity, and stop for reduced motion.
You can check items 2 to 4 in one place: build or paste your gradient into the CSS gradient generator, read its contrast and paint-cost checks, and export CSS with the fallback already included. To put a gradient inside your headings without breaking accessibility, see how to add a gradient to text in CSS.
Frequently asked questions
Why does my gradient have visible stripes?
That is banding: two similar colors spread over a large area leave too few distinct color steps. Add a subtle noise layer, widen the color difference or add an intermediate stop.
Does fading to transparent still turn grey?
Not in browsers that follow the specification, which interpolates in premultiplied RGBA. Fading to the same color at zero alpha is still a safe habit for very old engines.
How do I check contrast on a gradient?
Measure the text color against the end of the gradient that is closest in lightness to the text. If that point passes, the rest of the gradient does too.
Is it bad to animate a gradient?
Animating background-position or the gradient itself repaints every frame. Move or fade a gradient layer with transform or opacity instead, and respect prefers-reduced-motion.
Sources
- CSS Images Module Level 3, W3C (accessed October 12, 2026)
- CSS Color Module Level 4, W3C (accessed October 12, 2026)
- Using CSS gradients, MDN Web Docs (accessed October 12, 2026)
- Understanding Success Criterion 1.4.3: Contrast (Minimum), W3C Web Accessibility Initiative (accessed October 12, 2026)
- Stick to Compositor-Only Properties and Manage Layer Count, web.dev (accessed October 12, 2026)
How we made this guide
Drafted with AI assistance from the sources listed below, then checked line by line against those sources and the tool by a human editor. Finance, health and accounting guides are also reviewed by a qualified specialist before they are indexed.