CSS Linear Gradient Background
A linear gradient background in pure CSS: navy through purple to red at any angle. Pick all three colors and drag the angle, then copy CSS or Tailwind.
.bg-linear-gradient {
--c1: #223b8c;
--c2: #880088;
--bg: #cc3f47;
--angle: 135deg;
background-color: var(--bg);
background-image: linear-gradient(var(--angle), var(--c1), var(--c2), var(--bg));
}<div class="
[--c1:#223b8c]
[--c2:#880088]
[--bg:#cc3f47]
[--angle:135deg]
[background-color:var(--bg)]
[background-image:linear-gradient(var(--angle),_var(--c1),_var(--c2),_var(--bg))]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Linear Gradient — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-linear-gradient {
--c1: #223b8c;
--c2: #880088;
--bg: #cc3f47;
--angle: 135deg;
background-color: var(--bg);
background-image: linear-gradient(var(--angle), var(--c1), var(--c2), var(--bg));
}
</style>
</head>
<body class="bg-linear-gradient"></body>
</html>Save the pattern as an image, with your current colors and settings.
How this linear gradient works
A linear-gradient() blends colors along a straight line. This one has three stops, --c1, --c2 and --bg, with no positions, so CSS spaces them evenly: the start color at 0%, the middle at 50% and the end at 100%.
--angle sets the direction. 0deg runs bottom to top, 90deg left to right, 180deg top to bottom, and the default 135deg runs from the top-left corner to the bottom-right. Angles are measured clockwise from “up”, which is why 90deg points right.
The default blend runs navy, purple and red, neighbors on the brand color wheel, so the middle stays rich instead of muddy. Colors from opposite sides of the wheel tend to turn grey where they meet. If you need two far-apart colors, put a third color between them.
background-color is set to the end color too, so the element still has a matching color in the rare case the gradient doesn’t load.
Use it for hero sections, buttons, cards and full-page backgrounds. The Tailwind tab outputs the same gradient for Tailwind v4.