When coding color gradients in CSS, your generally need two colors because this is essentially a transition display. That means the top color (background-color) and the bottom color (color). CSS provides a method to easily generate a gradient from a palette using background-image and background-repeat. With the right CSS code, you can create a a gradient from a given palette of colors, but there's at least one way to do it with just a single hexadecimal color.
Step 1: Choose a color and a size
There's a pretty good chance your using a gradiant for a background. This means you need to choose the top color (your background-color) and the bottom color (your background-image). Remember that when you're creating a gradient in CSS you're going to create two CSS rules for the top color and the bottom color (a gradient between the two). In this tutorial we're going to create a purple gradient in three steps.
Step 2: Choose an RGB color
First choose a single color you like. This will be the top color for your gradient. You can choose a bright purple but you can also choose any color you like. Your probably thinking "Wait, that's it? I already know how to make a color with CSS". We're going to use hexadecimal color notation, but you can't specify any color with CSS.
What we'll do in this case is use HEX notation and a color picker to find the correct RGB value for that color. You can grab this color by hovering over any color in your browser. The color picker feature of a browser, such as Safari, Google Chrome, Firefox or Internet Explorer will display the color in your browser.
Choose the Top Color
A quick note on hex color notation: RGB color is written like this (without spaces): R = 255, G = 150, B = 20 It's also a lot easier to remember the RGB values of a color if you write it out as three digits separated by commas. The following RGB is equal to purple:
FF0000, 00, C0
RGB color can be written out like this, using three numbers and two colons: #FF0000:00:C0. For more information click here https://codepen.io/Zenin/pen/zYwNLNx.