CSS Rainbow Gradient Background
A rainbow gradient in pure CSS: seven brand colors from red through orange, yellow, green, teal and navy to purple. Pick each color and set the angle live.
.bg-rainbow-gradient {
--c1: #cc3f47;
--c2: #de6f3d;
--c3: #f09f33;
--c4: #4b9c41;
--c5: #167364;
--c6: #223b8c;
--bg: #880088;
--angle: 90deg;
background-color: var(--bg);
background-image: linear-gradient(var(--angle), var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c6), var(--bg));
}<div class="
[--c1:#cc3f47]
[--c2:#de6f3d]
[--c3:#f09f33]
[--c4:#4b9c41]
[--c5:#167364]
[--c6:#223b8c]
[--bg:#880088]
[--angle:90deg]
[background-color:var(--bg)]
[background-image:linear-gradient(var(--angle),_var(--c1),_var(--c2),_var(--c3),_var(--c4),_var(--c5),_var(--c6),_var(--bg))]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Rainbow Gradient — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-rainbow-gradient {
--c1: #cc3f47;
--c2: #de6f3d;
--c3: #f09f33;
--c4: #4b9c41;
--c5: #167364;
--c6: #223b8c;
--bg: #880088;
--angle: 90deg;
background-color: var(--bg);
background-image: linear-gradient(var(--angle), var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c6), var(--bg));
}
</style>
</head>
<body class="bg-rainbow-gradient"></body>
</html>Save the pattern as an image, with your current colors and settings.
How this rainbow gradient works
A rainbow gradient is one linear-gradient() with seven color stops in color-wheel order: red, orange, yellow, green, teal, navy and purple. With no positions given, CSS spaces them evenly, so each color gets the same share of the width.
Order is what keeps a rainbow bright. Each color only ever blends into its neighbor on the wheel, so the transitions stay vivid. Swap two colors that aren’t neighbors and you’ll get grey or brown bands between them.
--angle turns the bands. 90deg (the default) runs the rainbow left to right, 180deg stacks it top to bottom, and 135deg sweeps it diagonally.
These are the brand’s own palette colors, a little deeper than a pure spectrum, so the result looks designed rather than neon. For a flag look with sharp bands, give each color a start and end position, like var(--c1) 0 14%, var(--c2) 0 28%.
Use it for pride and celebration pages, kids’ sites, creative portfolios and playful section dividers.