Like this

.gradient {
  width: 500px;
  height: 200px;
  background: linear-gradient(to right, 
      red    20%, 
      green  20%, 
      green  40%, 
      blue   40%, 
      blue   60%, 
      purple 60%, 
      purple 80%, 
      yellow 80%,
      yellow 100%
  );
}
<div class="gradient"></div>

Answer from fen1x on Stack Overflow
🌐
CSS Gradient
cssgradient.io
CSS Gradient – Generator, Maker, and Background
Transitions in linear gradients occur along a straight line determined by an angle or direction. A CSS linear gradient can be coded by using the linear-gradient() function and can be as simple or complex as you would like. At the very least, you’ll only need two colors to get started.
Gradients
Looking for gradient inspiration? You’ve come to the right place. Browse our nicely curated collection of beautiful gradients in all colors: blue, red and more.
Color Shades
Color shades are lighter and darker variations of a particular color, created by adding white or black. Explore shades of red, blue, green, yellow, purple and pink.
Backgrounds
Discover the best gradient backgrounds from a curated collection of the ultimate list of gradient sites. With 1000+ gradients, it's easy to find the 👌 color!
CSS Gradient Text
These are typically referred to ... tell the code at which points each color should stop along the text gradient. These colors can be set as any type: named, HEX, RGB, or HSL. Because of this, there are a lot of different options when it comes to how your gradient can be shown. The most important part of your CSS gradient text is the actual CSS itself. Check out the basic form of the CSS · h1 { font-size: 72px; background: -webkit-linear-gradient(#eee, ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › gradient › linear-gradient
linear-gradient() - CSS - MDN Web Docs - Mozilla
The following three gradients are equivalent: ... linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); linear-gradient(red, orange 10% 30%, yellow 50% 70%, green 90%); linear-gradient(red 0%, orange 10% 30%, yellow 50% 70%, green 90% 100%);
🌐
ColorSpace
mycolor.space › gradient
ColorSpace - CSS Gradient Color Generator
New Feature: You can now create a gradient out of 3 colors! ... CSS Code: background-image: linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12);
🌐
W3Schools
w3schools.com › css › css3_gradients.asp
CSS Gradients
background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
🌐
uiGradients
uigradients.com
uiGradients - Beautiful colored gradients
A handpicked collection of beautiful color gradients for designers and developers
🌐
CSS-Tricks
css-tricks.com › almanac › functions › l › linear-gradient
linear-gradient() | CSS-Tricks
September 16, 2025 - Both options place a color a certain distance away from the gradient’s start, according to its direction, but while <length> works with absolute distances, <percentage>s are relative to the gradient’s box. The gradient box refers to the area where the gradient is displayed. It’s usually the element’s border box, but it can be modified through the background-size property. Learn more about the CSS Box Model in this article. .element1 { background-image: linear-gradient(lightsalmon 100px, lightcoral 200px); } .element2 { background-image: linear-gradient(khaki 25%, darkturquoise); /* same as */ background-image: linear-gradient(khaki 25%, darkturquoise 100%); }
🌐
W3Schools
w3schools.com › cssref › func_linear-gradient.php
CSS linear-gradient() function
linear-gradient(side-or-corner, angle, color-stop1, color-stop2, ...);
🌐
CSS Gradient
cssgradient.io › blog › css-gradient-text
CSS Gradient Text – CSS Gradient
Check out the basic form of the CSS · h1 { font-size: 72px; background: -webkit-linear-gradient(#eee, #333); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
Find elsewhere
🌐
ColorSpace
mycolor.space › gradient3
ColorSpace - 3 Color Gradient
ColorSpace · CSS Code: background-image: linear-gradient(to right top, #d16ba5, #c777b9, #ba83ca, #aa8fd8, #9a9ae1, #8aa7ec, #79b3f4, #69bff8, #52cffe, #41dfff, #46eefa, #5ffbf1);
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Values › gradient
<gradient> - CSS - MDN Web Docs - Mozilla
They are generated with the linear-gradient() function. Radial gradients transition colors progressively from a center point (origin). They are generated with the radial-gradient() function.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › linear-gradient
linear-gradient() - CSS | MDN
November 16, 2020 - The following three gradients are equivalent: ... linear-gradient(red 0%, orange 10%, orange 30%, yellow 50%, yellow 70%, green 90%, green 100%); linear-gradient(red, orange 10% 30%, yellow 50% 70%, green 90%); linear-gradient(red 0%, orange 10% 30%, yellow 50% 70%, green 90% 100%);
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › CSS_images › Using_CSS_gradients
Using CSS gradients - MDN Web Docs
To create the most basic type of gradient, all you need is to specify two colors. These are called color stops. You must have at least two, but you can have as many as you want. ... By default, linear gradients run from top to bottom.
🌐
ColorZilla
colorzilla.com › gradient-editor
Ultimate CSS Gradient Generator - ColorZilla.com
» Support for radial and diagonal linear gradients · » Support for full multi-stop gradients in Internet Explorer 9 (IE9) using SVG · » Support for Sass SCSS format using Compass mixins (needs latest beta of Compass) » Copy to clipboard button for quickly grabbing the generated code · » Easy resizing of preview panel by dragging its corner ... · Create transparent css gradients, or add fade-in, fade-out, semi-transparency and similar effects
🌐
W3Schools
w3schools.com › colors › colors_gradient.asp
Colors Gradient
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
upGrad
upgrad.com › home › tutorials › software & tech › linear gradient css
Linear Gradient in CSS with Code Examples [2026]
2 weeks ago - To create a conic gradient that ... effects, such as fading effects · To make a linear gradient in CSS, use the linear-gradient() function....
🌐
freeCodeCamp
freecodecamp.org › news › css-linear-gradient-explained-with-examples
CSS Linear Gradient Explained with Examples
February 1, 2020 - background: linear-gradient(to right, red , yellow); ... You can also transition a gradient diagonally by specifying the horizontal and vertical starting positions, for example, top-left, or bottom-right.
🌐
WebGradients
webgradients.com
WebGradients - Free CSS Gradients for Backgrounds and UI by itmeo
WebGradients is a free collection of 180 linear gradients that you can use as content backdrops in any part of your website. Easy copy CSS3 crossbrowser code and use it in a moment! We've also prepared a .PNG version of each gradient.
🌐
CSS-Tricks
css-tricks.com › css3-gradients
CSS Gradients | CSS-Tricks
January 26, 2021 - Perhaps the most common and useful type of gradient is the linear-gradient(). The gradients “axis” can go from left-to-right, top-to-bottom, or at any angle you chose. ... Those comma-separated colors can type of color you normally use: ...