CSS Dark Gradient Background

A dark gradient background in pure CSS: deep purple, navy and teal that shift subtly across the page, perfect behind light text. Pick the three colors.

#6f006f
#222564
#195654
.bg-dark-gradient {
  --c1: #6f006f;
  --bg: #222564;
  --c2: #195654;
  background-color: var(--bg);
  background-image: linear-gradient(160deg, var(--c1) 0%, var(--bg) 55%, var(--c2) 100%);
}
<div class="
  [--c1:#6f006f]
  [--bg:#222564]
  [--c2:#195654]
  [background-color:var(--bg)]
  [background-image:linear-gradient(160deg,_var(--c1)_0%,_var(--bg)_55%,_var(--c2)_100%)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Dark Gradient — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-dark-gradient {
      --c1: #6f006f;
      --bg: #222564;
      --c2: #195654;
      background-color: var(--bg);
      background-image: linear-gradient(160deg, var(--c1) 0%, var(--bg) 55%, var(--c2) 100%);
    }
  </style>
</head>
<body class="bg-dark-gradient"></body>
</html>

Save the pattern as an image, with your current colors and settings.

How this dark gradient works

A dark gradient background should feel rich without fighting your content. This one uses the darkest step of three brand colors: deep purple, navy and teal.

It’s a single linear-gradient(160deg, …). Deep purple starts in the top-left, navy fills the middle (55%) and teal finishes in the bottom-right. The angle is just off vertical, so the shift reads as light falling across the page rather than stripes.

The three colors are close in brightness, so contrast stays even everywhere. White or pale text passes contrast checks on all of them, so it doesn’t matter where a heading lands. The navy middle is also set as background-color, so the page looks right even before the gradient paints.

For more glow, swap the middle stop for a lighter color, or add a soft radial-gradient() on top.

Use it for dark-mode sites, developer tools, gaming and music pages, and app dashboards.

All CSS background gradients →