How-To Guides · Beginner
CSS Gradient Guide: Linear, Radial & Color Stops
Learn how CSS gradients work, set linear gradient angles, position color stops, create radial effects, improve contrast and copy CSS with Editagram’s Gradient Generator.
What is a CSS gradient?
A CSS gradient paints a smooth transition between two or more colors. It is generated by the browser as an image, so you can use it in properties such as background or background-image without creating a separate image file. Gradients are useful for page backgrounds, buttons, cards, overlays and decorative accents.
Linear gradients and angle direction
A linear gradient moves along a straight line. CSS uses an angle or a direction keyword to set that line. For example, linear-gradient(135deg, #2563eb, #14b8a6) creates a diagonal transition between blue and teal. The direction changes where each color appears; test the result in the actual component rather than assuming the angle is measured like a compass bearing.
Color stops and transitions
A color stop tells the browser where a color should appear along the gradient line. You can provide positions such as 0%, 50% and 100% to control the transition. Multiple stops can create a more layered effect, while two close stops can create a sharper color boundary. Keep the sequence intentional so the colors blend in the way you expect.
Radial gradients for spotlight effects
A radial gradient spreads outward from a center point and can be circular or elliptical. The radial-gradient() function accepts a shape, size, position and color stops. Use a subtle radial highlight behind a card or hero area, and adjust the center when the focal point should sit away from the middle.
Conic gradients and other CSS options
CSS also supports conic gradients, which sweep colors around a center point. They can be useful for charts, rings and color-wheel effects, although they are not the same as a straight-line or radial transition. The Editagram Gradient Generator focuses on its available linear and radial controls; you can add other CSS gradient functions manually when your design needs them.
Create and copy a gradient with Editagram
Open the Gradient Generator, choose the available gradient type, select colors, adjust the direction for a linear gradient, and review the live preview. Copy the generated CSS and paste it into your stylesheet or component. Check the generated rule in the context where it will be used, because a background image may sit above a fallback background color.
tip
Accessibility: keep text readable
A decorative gradient can make foreground text harder to read when the background changes brightness or hue. Check contrast at the lightest and darkest parts behind the text, not only at one point. For normal-sized text, WCAG AA generally calls for a contrast ratio of at least 4.5:1; large text has a lower threshold. Do not use color alone to communicate important information.
Performance and responsive design
Simple CSS gradients are usually inexpensive, but very large layered backgrounds, animated gradients and heavy blur effects can add rendering work—especially on lower-powered phones. Prefer a small number of layers, avoid animating large areas unless necessary, and test the page on a real mobile device. A gradient should support the content rather than compete with it.