On this page
I have built dark themes for apps and brand sites for 12 years, and a black gradient is the fastest way to make a flat dark screen feel deep. Use the studio above to move the stops, change the angle or switch to radial, then copy the CSS. The sections below cover the details that decide whether a dark gradient looks premium or muddy.
The basic black gradient CSS, line by line
The starting point is three stops: black in the top-left corner, charcoal through the middle and grey at the far edge.
.hero {
background: linear-gradient(135deg, #000000 0%, #333333 55%, #808080 100%);
}
The 135deg angle runs diagonally from top-left to bottom-right, which feels natural because light seems to fall from a corner. Use 180deg for a top-to-bottom fade under a header and 90deg for horizontal bars. I put the charcoal stop at 55% rather than 50% so the black area stays a little larger, which gives text on the left more room.
Radial and conic types change the mood. A spotlight such as radial-gradient(circle at 30% 20%, #333333, #000000 70%) works well behind a product shot, and conic-gradient(from 45deg, #000000, #808080, #000000) gives a brushed metal look for dials and buttons.
Black, charcoal and grey: exact color codes
All three anchor colors are neutral. Their red, green and blue values are equal, so saturation is 0% and only lightness changes. I added because many dark interfaces start from it.
| Color | HEX | RGB | HSL | CMYK |
|---|---|---|---|---|
| Black | 0, 0, 0 | 0°, 0%, 0% | 0, 0, 0, 100 | |
| Charcoal | 51, 51, 51 | 0°, 0%, 20% | 0, 0, 0, 80 | |
| Grey | 128, 128, 128 | 0°, 0%, 50% | 0, 0, 0, 50 | |
| Surface black | 18, 18, 18 | 0°, 0%, 7% | 0, 0, 0, 93 |
The CMYK figures are plain conversions from RGB, so a real press profile will give different numbers. Treat them as a starting point. sits at exactly 20% lightness, a tidy step for text and cards, and is within a hair of true 50%.
Next to close colors, is the floor: nothing can be darker, so shadows vanish on it. Near blacks like and still read as black but leave room to show depth. is clearly dark grey, which most people call charcoal.
Why pure black can look harsh, and what to use instead
On an OLED phone, pixels emit no light. That gives superb contrast, but bright text on a pure black page can feel glaring, and dark areas next to lighter ones sometimes look smeared when you scroll.
Which is the better base for a large dark mode surface?
A near black like #121212 leaves room to show elevation, while pure black flattens every layer into one.
Google’s Material Design dark theme guidance starts from for the base surface and raises cards with lighter steps. I follow the same idea on client work: the page sits at , cards at , and appears only at the deepest end of a gradient.
Keep for the single deepest point. Build everything else from up to so you still have darker and lighter steps to play with.
Pure black still has its place. Cinema sites, photo portfolios and audio brands often want a true void, and a gradient that fades into at one edge gives that without flattening the whole page.
Black gradients for dark mode and UI surfaces
Serve the dark gradient only when the visitor’s system asks for it. The prefers-color-scheme media query handles that in a few lines.
body { background: #ffffff; }
@media (prefers-color-scheme: dark) {
body { background: linear-gradient(180deg, #121212 0%, #000000 100%); }
}
A few habits keep dark UI gradients calm:
- Keep the lightest stop on large surfaces near or darker, so white text stays comfortable.
- Lift cards by a few steps ( on a page) instead of leaning on heavy shadows.
- Keep the shift gentle. A change of 10 to 20 values per channel is often enough to add depth.
- Check the result on a real phone at low brightness, not only on a bright monitor.
If you want to explore the lighter end of this scale, the gray gradient page has ready-made mid and light grey fades.
Black to transparent: image overlays that keep text readable
This is the most common real-world use. A photo with a caption needs a darker zone behind the words, and a black-to-transparent layer on top of the image does it.

.hero {
background:
linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 60%),
url(photo.jpg) center / cover;
}
The gradient layer is listed first, so it paints above the image. Fading black to transparent never goes muddy, because transparent is black with zero opacity. If you fade another color, write that same color at zero alpha so the midpoint stays clean.
For a smoother result, add a middle stop such as rgba(0,0,0,0.4) 30%. It eases the curve so there is no visible edge where the shade ends.
How to stop banding in dark gradients
Screens use 256 levels per color channel. Between and there are only 52 grey values, so on a 1920 pixel wide hero each step is roughly 37 pixels wide. Your eye picks those steps out as stripes, especially on bright monitors.
Four fixes work reliably:
- Lengthen the range, for instance ending at instead of .
- Add a faint hue. Blending into uses all three channels, so there are more distinct steps.
- Overlay a subtle noise texture at low opacity to break up the edges.
- Interpolate in a perceptual space with
linear-gradient(in oklch 135deg, ...), and keep a plain line above it as a fallback.
Try this: In the studio, set a 180deg gradient from to , then change only the end stop to . Compare the band edges on your phone at low brightness.
I once shipped a launch page where the banding only showed on the client’s bright office monitor. A faint blue tint in the end stop solved it without changing the look.
Contrast and WCAG on black gradients
WCAG AA asks for at least 4.5:1 for normal text and 3:1 for large text and interface components. These ratios are calculated from the actual luminance of each color:
- White on : 21:1, the maximum possible.
- White on : 12.6:1.
- on : 5.3:1, which passes for body text.
- on : 3.2:1, large text only.
- White on : 3.95:1, which fails for body text.
With a gradient, test the lightest stop that sits behind the text, not the average. On our default blend, white text over the grey corner falls short of AA for small copy.
Which text and background pair passes WCAG AA for body text?
Grey #808080 on black measures about 5.3:1, while the other two pairs fall below 4.5:1.
On one hero I fixed, grey captions sat over the lightest corner of a fade. I moved the end stop to and switched the captions to white, and every pixel behind the text then cleared 12:1.

Adding color: black gradients with gold, red and blue
A purely neutral black gradient can look flat. A hint of hue gives it character without losing the dark feel. Cool tints like into feel technical and calm, while warm ones like into feel cinematic.
Black into gold is the classic luxury pairing, and our black and gold page has palettes for it. For drama, a black base with a deep glow from the red gradient family suits sports, gaming and music pages. A dark violet such as echoes the blue to purple gradient and gives a night sky mood.
Keep any tint very dark so white text still passes contrast. If you want a restrained neutral partner for secondary elements, the black and grey combination page lists tested pairs.
Black gradients in print, branding and interiors
Print and CMYK
In CMYK, black built from the K channel alone (0, 0, 0, 100) often prints less deep than expected, so many printers recommend a rich black that adds other inks. Ask your printer for their recipe and ink limit rather than guessing.
A print proof once surprised me: a to fade on a brochure showed visible steps on uncoated stock, and the flat K-only black looked washed beside the cover’s rich black. Since then I add subtle texture or a slight hue to print gradients and always order a proof.
Brand, interiors, fashion and art
In branding, black gradients suit luxury, audio, automotive and tech, where a white wordmark pops against the dark. A light neutral like pastel gray works well for secondary text without the glare of pure white.
In interiors, a matte charcoal wall under directional lighting creates a natural black-to-grey fade. In fashion, ombré dye work moves from black to grey along a hem, and in art, graphite and charcoal shading is a gradient made by hand.
Four black palettes ready to copy
Each palette below starts from a near black and ends with a light tone for text, so the set works straight away in a dark layout. Swap the accent for your own brand color and test contrast again.
Neutral dark UI with a clean off white for text and icons.
Cool tech dashboards, developer tools and night sky hero sections.
Photography portfolios, cinema sites and cozy editorial layouts with soft contrast.
Luxury packaging, event invitations and premium product pages with a bright accent.
Studio Night is neutral and safe for apps. Midnight Ink adds a cool slate range, Warm Graphite leans brown for editorial work, and Gold Leaf Noir brings in a single bright accent for premium pages.
The colors behind these gradients
Black Gradient: questions people ask
How do you make a black gradient in CSS?
Use linear-gradient with two or more dark stops, for example linear-gradient(135deg, #000000, #333333, #808080). Change the angle for direction, or switch to radial-gradient for a spotlight effect.
What hex code is best for a dark mode background?
A near black such as #121212 is a safer base than pure #000000 for large surfaces. It leaves room to show raised cards in slightly lighter steps like #1E1E1E.
Why does my black gradient look stripy?
Screens use 256 levels per channel, and dark gradients cover very few of them, so steps become visible. Lengthen the range, add a faint hue such as #0F172A, or overlay light noise to hide the bands.
What are the hex codes for black, charcoal and grey?
Black is #000000, charcoal is #333333 and mid grey is #808080. In RGB these are 0, 0, 0, then 51, 51, 51, then 128, 128, 128.
Is white text on a black gradient accessible?
White on #000000 reaches 21:1 and white on #333333 reaches 12.6:1, so both pass WCAG AA easily. Check the lightest stop behind your text, because white on #808080 is only 3.95:1.
Keep exploring
- Brown Gradient: Dark Brown Gradient Colors, Hex Codes and CSS
- Pastel Green Gradient: Backgrounds, Wallpapers and CSS Codes
- Rainbow Gradient: Colors, Backgrounds and CSS Codes
- Green Gradient: Color Combinations, Hex Codes and CSS
- Bronze Gradient: Wallpaper Colors, Hex Codes and CSS
- Blue Grey Gradient: Color Codes and CSS Examples
- Honey Blonde Color: Hex Code, RGB and Palettes
- Light Green Color: Hex Code, RGB and Palettes