CSS Gradient Not Showing Up? Here's Why and How to Fix It

Published October 24, 2026 · 7 min read · Design

Last updated: October 24, 2026

CSS Gradient Generator

Build linear, radial, and conic gradients visually and copy clean CSS instantly.

Try It Free →

You write a perfectly reasonable background: linear-gradient(...), save the file, refresh the browser, and see nothing. No error in the console, no red underline in your editor. The element just sits there, flat and colorless. This happens more often than it should, and the cause is almost always one of a small set of well-known mistakes. This guide covers each one, explains why it happens, and shows the exact fix.

Last updated: July 2026

The Most Common Reason: The Element Has No Height

A gradient is a background image, not a color. If the element containing it has no defined height and no content to push it open, the browser renders a box with zero height. A zero-height box shows nothing, even if the gradient syntax is perfect.

This trips up developers most often on div elements. A div is block-level but takes only as much height as its content. If it is empty, it collapses.

How to fix it

  • Add an explicit height: height: 200px; or min-height: 200px;
  • Use height: 100vh; for full-viewport sections
  • Add padding so the content expands the box: padding: 2rem;
  • On a flex or grid container, make sure children are actually present

Quick diagnostic: open DevTools, inspect the element, and check its computed height. If it reads 0px, the element is collapsing. Fix the height first, then check whether the gradient appears.

Using background-color Instead of background or background-image

This is a syntax mistake that produces no browser warning. background-color accepts a single color value. If you paste a gradient function there, the browser ignores the entire declaration silently.

/* Wrong */
background-color: linear-gradient(to right, #ff6b6b, #feca57);

/* Correct */
background: linear-gradient(to right, #ff6b6b, #feca57);
/* or */
background-image: linear-gradient(to right, #ff6b6b, #feca57);

Use background (shorthand) or background-image. Either works. The shorthand is more common in practice because it is shorter and resets other background sub-properties at the same time.

A Later Rule Is Overriding Your Gradient

CSS cascades. If a stylesheet loaded after yours, or a more specific selector in the same stylesheet, sets a solid background or background-color, it can wipe out your gradient. This is especially common when working inside a CSS framework like Bootstrap or Tailwind, which set their own background utilities.

How to diagnose it

  1. Open DevTools and click on the element.
  2. In the Styles panel, look for your gradient rule. If it has a strikethrough, it is being overridden.
  3. Identify which rule is winning and either increase your selector specificity or remove the conflicting rule.

A quick but not always appropriate fix is adding !important. A better fix is tightening your selector. For example, change .card to .hero .card if the context allows it.

Gradient on Text Is Invisible Without Clip and Color Reset

Applying a gradient to text requires three CSS properties working together. Forgetting any one of them leaves the text either invisible or showing a solid color.

/* All three lines are required */
background: linear-gradient(to right, #6a11cb, #2575fc);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
  • background: sets the gradient as the background of the element
  • -webkit-background-clip: text clips the background to the shape of the text characters
  • -webkit-text-fill-color: transparent makes the actual text fill transparent so the background shows through

If you skip -webkit-text-fill-color: transparent, the solid text color sits on top of the gradient and hides it completely. If you skip the clip, you see the gradient behind the text, not inside it. Note that background-clip: text (without the -webkit- prefix) now has broad support, but the -webkit- prefixed version is still needed for Safari compatibility as of 2026.

If you want to check that your gradient text still passes readability standards when placed on a page, run the colors through EveryFreeTool's contrast checker to verify legibility against surrounding backgrounds.

Missing or Malformed Gradient Syntax

The gradient functions have strict syntax. A missing parenthesis, a comma in the wrong place, or an invalid color value causes the entire declaration to be dropped. Common mistakes include:

  • Writing linear gradient with a space instead of linear-gradient
  • Using to right top instead of the correct to top right for diagonal directions
  • Forgetting the degree symbol: writing 90 instead of 90deg
  • Using an invalid hex color like #GGG instead of a valid value like #CCC
  • Omitting the closing parenthesis on the function

The fastest way to avoid all of these is to generate the gradient visually. EveryFreeTool's CSS gradient generator outputs syntactically valid CSS every time, so you can copy it directly into your project without worrying about a typo breaking the rule silently.

The Gradient Is There But Invisible Because the Colors Are Too Similar

If you set both color stops to nearly identical values, the gradient renders correctly but looks like a flat color. This is not a bug. It is worth checking when you are sure the syntax is right but the element looks wrong.

Use EveryFreeTool's color picker to confirm the exact hex values you are using. If the lightness values are within a few percentage points of each other, increase the contrast between stops. A color palette generator can help you find stop colors that are visually distinct but still harmonious.

Gradient Behind an Image or Pseudo-element Is Hidden

Sometimes a gradient is correctly applied but is completely covered by another element. Two situations cause this frequently:

A background image is stacking on top

When you use the background shorthand to add both a background image and a gradient, the order matters. CSS background layers stack with the first value on top. If your image is listed first, it covers the gradient.

/* Image covers gradient entirely if the image is opaque */
background: url(photo.jpg), linear-gradient(to bottom, #000, #333);

/* Put gradient first if you want it visible when image is absent */
background: linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0.8)), url(photo.jpg);

A pseudo-element is covering the gradient

If a ::before or ::after pseudo-element is positioned over the parent without a transparent background, it blocks the gradient from view. Check z-index stacking and the background of any pseudo-elements on the element.

Vendor Prefix Issues on Older or Niche Browsers

Modern browsers handle unprefixed gradients without issue. However, if you are supporting very old WebKit builds or a browser with unusual rendering, the unprefixed syntax may not work. Adding the -webkit- prefix as a fallback covers most edge cases:

background: -webkit-linear-gradient(left, #ee0979, #ff6a00);
background: linear-gradient(to right, #ee0979, #ff6a00);

Always put the standard (unprefixed) declaration last so it overrides the prefixed version in browsers that support both.

A Practical Debugging Checklist

When a gradient is not showing, go through these steps in order:

  1. Inspect the element in DevTools. Confirm its computed height is greater than zero.
  2. Check that you used background or background-image, not background-color.
  3. Look for strikethrough rules in DevTools that indicate the gradient is being overridden.
  4. Paste your CSS into a gradient generator to confirm the syntax is valid.
  5. If applying to text, confirm all three required properties are present.
  6. If using a background image alongside the gradient, check the stacking order.
  7. Check for pseudo-elements or absolutely positioned children that may be covering the element.

Working through this list resolves the problem in nearly every case. If the gradient still does not appear after all seven steps, copy the element's full computed styles from DevTools and test it in a blank HTML file to isolate the issue from framework styles.

For building and testing gradients quickly without writing CSS by hand, the CSS gradient generator on EveryFreeTool is a reliable starting point. It generates clean, ready-to-paste code for linear, radial, and conic gradients.

Color Picker

Pick exact hex, RGB, or HSL values to use in your gradient stops.

Try It Free →

Frequently Asked Questions

Why does my CSS gradient show in Chrome but not Safari?

Safari has historically required the <code>-webkit-</code> prefix for some gradient features, particularly <code>-webkit-background-clip: text</code> for gradient text effects. Add both the prefixed and unprefixed versions to your CSS, with the unprefixed version listed last. For standard background gradients, Safari has supported unprefixed syntax since version 7, so if it is broken on a modern Safari, the cause is more likely a specificity or syntax issue than a prefix problem.

Can I animate a CSS gradient?

You cannot directly animate a CSS gradient using standard CSS transitions because gradients are treated as images, not color values, and transitions cannot interpolate between two image values. A common workaround is to animate the <code>background-position</code> of an oversized gradient, creating a shifting color effect. Another approach is to animate pseudo-element opacity or use the CSS Houdini <code>@property</code> API to register the color stops as animatable typed values, which works in Chromium-based browsers as of 2026.

Why is my gradient text not showing on Firefox?

Firefox supports <code>background-clip: text</code> without the <code>-webkit-</code> prefix, but it also requires <code>-webkit-text-fill-color: transparent</code> or the equivalent <code>color: transparent</code> for the gradient to show through the text characters. Make sure all three properties are present: the background gradient, the clip, and the transparent fill. If you are using a CSS framework that sets a text color with high specificity, that color declaration may override your transparent fill.

My gradient shows in my CSS file but a framework is overriding it. What should I do?

Open browser DevTools, find the element, and look in the Styles panel for your gradient rule with a strikethrough through it. The rule listed below it with a higher specificity or later source order is winning. The cleanest fix is to increase your selector's specificity by adding a parent class or element to it. Avoid using <code>!important</code> unless the framework itself uses it, because it makes future maintenance harder.

Does a CSS gradient work on borders?

CSS does not allow <code>border-color</code> to accept a gradient directly. The standard technique is to use <code>border-image</code> with a gradient value, but this removes border-radius support. A more flexible method is to apply the gradient as a background on the element itself, set the border to transparent, and use <code>background-clip: padding-box</code> combined with a wrapper or pseudo-element technique to simulate a gradient border with rounded corners. It requires a few extra lines but works reliably across modern browsers.

Related Tools

🔒 Your data stays in your browser
Need help? Email us