How to Make a CSS Gradient (Linear & Radial)

Short answer
A basic linear gradient is background: linear-gradient(135deg, #0ea5e9, #6366f1);. Add colour stops and angles as needed — or design visually in our CSS gradient generator.
Searches for “css generator gradient” usually want working CSS fast. You can type it by hand or build it visually and copy the code.
Linear gradients
background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
Angle 0deg points up; 90deg left-to-right. Stops can include percentages.
Radial gradients
background: radial-gradient(circle at center, #fde68a, #f59e0b);
Fallbacks and contrast
Put a solid colour before the gradient for older browsers. Check text contrast after you pick colours — convert HEX with the color converter.
Minify for production
After you paste gradients into a stylesheet, compress with the CSS minifier.
Design tips
- Two or three stops usually look cleaner than six.
- Keep brand colours consistent across buttons and heroes.
- Test in light and dark UI modes.
Open the free css gradient generator to check your result.
See also: how to convert hex to rgb.
See also: what is base64 encoding.
See also: how to fix invalid json.
More worked numbers
Change one input at a time so you build intuition. Write the formula, substitute values, then confirm with the free css gradient generator. If the tool disagrees with your hand math, check units first (months vs years, percent vs decimal, inclusive ranges).
Common mistakes to avoid
- Mixing up percent and decimal forms (15% is 0.15, not 15).
- Using the wrong base when calculating a change or a reverse percentage.
- Ignoring fees, tax or daylight saving when the real-world total depends on them.
- Rounding too early in multi-step arithmetic.
How to practise
Invent three mini-problems from your own life — a bill, a grade, a trip, a loan quote — and solve them on paper before you open the calculator. Teaching the steps to someone else is one of the fastest ways to lock in the method.
Related tools on ViralScopeHub
After you finish this guide, explore the linked tools above and the related articles for neighbouring skills. Our calculators run privately in your browser with no sign-up, so you can check homework, budgets or work estimates without uploading data.
Quick reference card
Keep the short answer box at the top of this page as your cheat sheet. When a search result brought you here for a specific phrase, that box is designed to match the query with the formula first, then the examples below fill in the judgement calls.
Frequently asked questions
What is the CSS for a linear gradient?
background: linear-gradient(angle, colour1, colour2); Double-check units and confirm with the linked tool on this page before you rely on the figure for money or school decisions.
Do gradients work in all browsers?
Linear and radial gradients work in all modern browsers; conic is widely supported too. Double-check units and confirm with the linked tool on this page before you rely on the figure for money or school decisions.
How do I get CSS without writing it?
Use our CSS gradient generator and click Copy. Double-check units and confirm with the linked tool on this page before you rely on the figure for money or school decisions.
Can I use HEX and RGB together?
Yes. Convert freely with the color converter. Double-check units and confirm with the linked tool on this page before you rely on the figure for money or school decisions.