Skip to main content

Gradient Generator

Create CSS gradient code from color stops with linear, radial, and conic options. Enter values for instant results with step-by-step formulas.

Skip to calculator
Creative & Design

Gradient Generator

Create CSS gradient code from color stops with linear, radial, and conic options. Preview gradients live and copy ready-to-use CSS code for your web projects.

Last updated: December 2025

Calculator

Adjust values & calculate
135deg
Very smooth transition | 2 colors
CSS Code
background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
Tailwind CSS (approximate)
bg-gradient-to-br with custom colors #3B82F6 -> #8B5CF6
#3B82F6
#636ff6
#8B5CF6
Direction
to bottom right
Color Distance
89

Repeating Variant

Tip: CSS gradients are rendered by the browser GPU and have zero file size impact. Use them instead of gradient images for better performance and scalability.
Your Result
background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
Share Your Result
Understand the Math

Formula

linear-gradient(angle, color1 stop1%, color2 stop2%) | radial-gradient(shape, colors) | conic-gradient(from angle, colors)

CSS gradients define smooth transitions between colors. Linear gradients follow a straight line at a specified angle, radial gradients expand outward from a center point, and conic gradients rotate around a center point. Color stops define where each color appears in the transition.

Last reviewed: December 2025

Worked Examples

Example 1: Modern Blue-Purple Linear Gradient

Create a 135-degree linear gradient from #3B82F6 (blue) to #8B5CF6 (purple) for a hero section background.
Solution:
Type: linear-gradient Angle: 135deg (top-left to bottom-right) Color 1: #3B82F6 at 0% Color 2: #8B5CF6 at 100% CSS: background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%); Tailwind: bg-gradient-to-br from-blue-500 to-violet-500 Color distance: 123 (smooth transition)
Result: CSS: background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);

Example 2: Three-Color Sunset Gradient

Create a warm gradient with orange, pink, and purple for a card background.
Solution:
Type: linear-gradient Angle: 135deg Color 1: #F97316 (orange) at 0% Color 2: #EC4899 (pink) at 50% Color 3: #8B5CF6 (purple) at 100% CSS: background: linear-gradient(135deg, #F97316 0%, #EC4899 50%, #8B5CF6 100%); Smooth analogous transition through warm spectrum
Result: CSS: background: linear-gradient(135deg, #F97316 0%, #EC4899 50%, #8B5CF6 100%);
Expert Insights

Background & Theory

The Gradient Generator applies the following established principles and formulas. Computers represent all information using binary, a base-2 number system consisting solely of the digits 0 and 1, each called a bit. Because long binary strings are unwieldy, programmers routinely use octal (base 8) and hexadecimal (base 16) as compact shorthand. Converting between bases follows a consistent algorithm: divide the source number repeatedly by the target base, collecting remainders in reverse order. Hexadecimal digits A through F represent the values 10 through 15, allowing a single character to encode four binary bits, making it the preferred notation for memory addresses, color codes, and bytecode. Bitwise operations manipulate individual bits within integers. AND produces a 1 only when both input bits are 1, making it useful for masking. OR produces a 1 when either bit is 1 and is used for combining flags. XOR flips bits that differ, enabling simple toggle logic and efficient swap algorithms. NOT inverts every bit (one's complement), while left and right shifts multiply or divide by powers of two in constant time. Data storage units ascend in binary multiples of 1024: 8 bits form one byte, 1024 bytes form one kibibyte (KiB), 1024 KiB form one mebibyte (MiB), and so forth. Hard-drive manufacturers historically use decimal prefixes (1 KB = 1000 bytes), creating the persistent confusion between binary and decimal interpretations of the same label. The IEC standardized the binary prefixes KiB, MiB, GiB, and TiB in 1998 to resolve this ambiguity. Network bandwidth is measured in bits per second (bps), most commonly megabits per second (Mbps) or gigabits per second (Gbps). A 100 Mbps connection transfers 100 million bits every second, equating to roughly 12.5 megabytes per second. IP subnet masks define network boundaries; CIDR notation appends a prefix length (e.g., /24) to an address, indicating how many leading bits are fixed. A /24 subnet contains 256 addresses with 254 usable hosts. Algorithm efficiency is described using Big-O notation, which characterises the worst-case growth of time or space relative to input size. O(1) is constant, O(log n) is logarithmic (binary search), O(n) is linear, and O(nยฒ) is quadratic. Cryptographic hash functions like SHA-256 produce a fixed 256-bit (32-byte) digest regardless of input length. File compression algorithms exploit statistical redundancy to reduce storage footprint, and compression ratio equals the original file size divided by the compressed size.

History

The history behind the Gradient Generator traces back through the following developments. The conceptual foundation of modern computing traces back to Charles Babbage, whose Analytical Engine design of 1837 introduced the idea of a general-purpose mechanical computer with separate storage and processing units, including what he called the Store and the Mill. Ada Lovelace wrote what many consider the first algorithm intended for machine execution while annotating a translation of Luigi Menabrea's account of Babbage's work, also recognising the machine's potential to manipulate symbols beyond mere numbers. George Boole published "The Laws of Thought" in 1854, formalising a two-valued algebra of logic that would later map perfectly to electrical circuits. It remained largely a mathematical curiosity until Claude Shannon's landmark 1937 master's thesis demonstrated that Boolean algebra could describe switching circuits, laying the theoretical groundwork for all digital electronics. Shannon's 1948 paper "A Mathematical Theory of Communication" defined the bit as the fundamental unit of information and established information theory as a rigorous discipline. The same year, the transistor was invented at Bell Labs by Bardeen, Brattain, and Shockley, eventually replacing vacuum tubes and enabling miniaturisation at scale. ENIAC, completed in 1945, was one of the first general-purpose electronic computers, occupying 1800 square feet and consuming 150 kilowatts of power while performing roughly 5000 additions per second. The ASCII standard was ratified in 1963, assigning 7-bit codes to 128 characters and enabling interoperability between computers from different manufacturers. Through the 1970s, the microprocessor consolidated an entire CPU onto a single chip; Intel's 4004 in 1971 marked the beginning of this trend. The Apple II launched in 1977 and the IBM PC in 1981 brought computing to homes and offices, triggering a mass-market software industry. Tim Berners-Lee proposed the World Wide Web in 1989 and launched the first website in 1991 at CERN, transforming the internet from an academic and military network into a global information infrastructure. Mobile computing accelerated through the 2000s with smartphones integrating powerful processors, wireless networking, and GPS into pocket-sized devices, extending computation into every facet of daily life and cementing TCP/IP as the universal communications fabric.

Share this calculator

Explore More

Frequently Asked Questions

CSS gradients are smooth transitions between two or more colors, rendered by the browser without requiring image files. There are three main types: linear-gradient (transitions along a straight line at a specified angle), radial-gradient (transitions outward from a center point in a circular or elliptical shape), and conic-gradient (transitions around a center point like a color wheel). Each type also has a repeating variant (repeating-linear-gradient, repeating-radial-gradient, repeating-conic-gradient) that tiles the gradient pattern. Gradients are technically CSS images and can be used anywhere an image value is accepted, including backgrounds, list-style-image, border-image, and even as mask images for advanced visual effects.
Color stops define the position where a specific color appears in the gradient, specified as a percentage (0% to 100%) or length value. The browser smoothly interpolates colors between adjacent stops. By default, colors are evenly distributed, but moving stop positions creates asymmetric transitions. For example, placing a stop at 70% instead of 50% makes the first color dominant for longer before transitioning. You can also use two positions for a single color (like 'blue 30% 60%') to create a solid band of that color within the gradient. Hard color stops (two different colors at the same position) create sharp lines instead of gradual transitions. Understanding stop positioning is key to achieving precise control over gradient appearance.
The best gradient color combinations follow color theory principles. Analogous colors (30-60 degrees apart on the color wheel) produce the smoothest, most natural gradients: blue to purple, green to teal, or orange to red. Monochromatic gradients (same hue, different lightness) are safe and elegant. For bolder designs, use complementary colors but add a middle stop to prevent muddiness. Popular gradient combinations include: blue to purple (tech and creative), orange to pink (warm and energetic), teal to green (nature and health), and dark blue to black (elegant and premium). Avoid combining warm and cool colors directly without an intermediate stop, as the midpoint often appears gray or brown.
Linear gradient angles in CSS specify the direction of the color transition. Zero degrees (0deg) points upward, and angles increase clockwise: 90deg points right, 180deg points down, and 270deg points left. CSS also accepts keyword directions: 'to right' equals 90deg, 'to bottom' equals 180deg, 'to top left' equals 315deg, and so on. Diagonal keywords like 'to bottom right' adapt to the element aspect ratio (the gradient line goes corner to corner), while angle values create fixed-angle gradients regardless of the element shape. The most common angles are 90deg (horizontal), 180deg (vertical), 135deg (diagonal top-left to bottom-right), and 45deg (diagonal bottom-left to top-right).
Radial gradients can use either a circle or ellipse shape. A circular radial gradient expands equally in all directions, maintaining a perfect circle regardless of the element dimensions. An elliptical gradient stretches to match the element aspect ratio, creating an oval that fills the element naturally. The default shape is ellipse. Size keywords control how far the gradient extends: closest-side stops at the nearest edge, farthest-side extends to the furthest edge, closest-corner stops at the nearest corner, and farthest-corner (default) extends to the furthest corner. You can also specify the center position using 'at X Y' syntax, such as 'radial-gradient(circle at 25% 75%, blue, red)' to offset the gradient origin from the element center.
CSS gradient borders can be created using the border-image property or the background technique. The border-image approach uses: border-image-source set to your gradient, border-image-slice set to 1, and border-width set to your desired thickness. However, border-image does not support border-radius. The more flexible background technique uses a gradient background on the element with a solid-color background on a pseudo-element or inner element to create the illusion of a gradient border. The padding between the backgrounds determines the border thickness. Another modern approach uses the CSS outline or box-shadow with gradient overlays. For rounded gradient borders, use a combination of background-origin, background-clip, and padding to achieve the effect with full border-radius support.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

linear-gradient(angle, color1 stop1%, color2 stop2%) | radial-gradient(shape, colors) | conic-gradient(from angle, colors)

CSS gradients define smooth transitions between colors. Linear gradients follow a straight line at a specified angle, radial gradients expand outward from a center point, and conic gradients rotate around a center point. Color stops define where each color appears in the transition.

Worked Examples

Example 1: Modern Blue-Purple Linear Gradient

Problem: Create a 135-degree linear gradient from #3B82F6 (blue) to #8B5CF6 (purple) for a hero section background.

Solution: Type: linear-gradient\nAngle: 135deg (top-left to bottom-right)\nColor 1: #3B82F6 at 0%\nColor 2: #8B5CF6 at 100%\nCSS: background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);\nTailwind: bg-gradient-to-br from-blue-500 to-violet-500\nColor distance: 123 (smooth transition)

Result: CSS: background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);

Example 2: Three-Color Sunset Gradient

Problem: Create a warm gradient with orange, pink, and purple for a card background.

Solution: Type: linear-gradient\nAngle: 135deg\nColor 1: #F97316 (orange) at 0%\nColor 2: #EC4899 (pink) at 50%\nColor 3: #8B5CF6 (purple) at 100%\nCSS: background: linear-gradient(135deg, #F97316 0%, #EC4899 50%, #8B5CF6 100%);\nSmooth analogous transition through warm spectrum

Result: CSS: background: linear-gradient(135deg, #F97316 0%, #EC4899 50%, #8B5CF6 100%);

Frequently Asked Questions

What is a CSS gradient and what types are available?

CSS gradients are smooth transitions between two or more colors, rendered by the browser without requiring image files. There are three main types: linear-gradient (transitions along a straight line at a specified angle), radial-gradient (transitions outward from a center point in a circular or elliptical shape), and conic-gradient (transitions around a center point like a color wheel). Each type also has a repeating variant (repeating-linear-gradient, repeating-radial-gradient, repeating-conic-gradient) that tiles the gradient pattern. Gradients are technically CSS images and can be used anywhere an image value is accepted, including backgrounds, list-style-image, border-image, and even as mask images for advanced visual effects.

What are color stops and how do they affect gradient appearance?

Color stops define the position where a specific color appears in the gradient, specified as a percentage (0% to 100%) or length value. The browser smoothly interpolates colors between adjacent stops. By default, colors are evenly distributed, but moving stop positions creates asymmetric transitions. For example, placing a stop at 70% instead of 50% makes the first color dominant for longer before transitioning. You can also use two positions for a single color (like 'blue 30% 60%') to create a solid band of that color within the gradient. Hard color stops (two different colors at the same position) create sharp lines instead of gradual transitions. Understanding stop positioning is key to achieving precise control over gradient appearance.

How do I choose gradient colors that work well together?

The best gradient color combinations follow color theory principles. Analogous colors (30-60 degrees apart on the color wheel) produce the smoothest, most natural gradients: blue to purple, green to teal, or orange to red. Monochromatic gradients (same hue, different lightness) are safe and elegant. For bolder designs, use complementary colors but add a middle stop to prevent muddiness. Popular gradient combinations include: blue to purple (tech and creative), orange to pink (warm and energetic), teal to green (nature and health), and dark blue to black (elegant and premium). Avoid combining warm and cool colors directly without an intermediate stop, as the midpoint often appears gray or brown.

How do linear gradient angles work in CSS?

Linear gradient angles in CSS specify the direction of the color transition. Zero degrees (0deg) points upward, and angles increase clockwise: 90deg points right, 180deg points down, and 270deg points left. CSS also accepts keyword directions: 'to right' equals 90deg, 'to bottom' equals 180deg, 'to top left' equals 315deg, and so on. Diagonal keywords like 'to bottom right' adapt to the element aspect ratio (the gradient line goes corner to corner), while angle values create fixed-angle gradients regardless of the element shape. The most common angles are 90deg (horizontal), 180deg (vertical), 135deg (diagonal top-left to bottom-right), and 45deg (diagonal bottom-left to top-right).

What is the difference between radial gradient circle and ellipse shapes?

Radial gradients can use either a circle or ellipse shape. A circular radial gradient expands equally in all directions, maintaining a perfect circle regardless of the element dimensions. An elliptical gradient stretches to match the element aspect ratio, creating an oval that fills the element naturally. The default shape is ellipse. Size keywords control how far the gradient extends: closest-side stops at the nearest edge, farthest-side extends to the furthest edge, closest-corner stops at the nearest corner, and farthest-corner (default) extends to the furthest corner. You can also specify the center position using 'at X Y' syntax, such as 'radial-gradient(circle at 25% 75%, blue, red)' to offset the gradient origin from the element center.

How do I create a CSS gradient border?

CSS gradient borders can be created using the border-image property or the background technique. The border-image approach uses: border-image-source set to your gradient, border-image-slice set to 1, and border-width set to your desired thickness. However, border-image does not support border-radius. The more flexible background technique uses a gradient background on the element with a solid-color background on a pseudo-element or inner element to create the illusion of a gradient border. The padding between the backgrounds determines the border thickness. Another modern approach uses the CSS outline or box-shadow with gradient overlays. For rounded gradient borders, use a combination of background-origin, background-clip, and padding to achieve the effect with full border-radius support.

References

Reviewed by Daniel Agrici, Founder & Lead Developer ยท Editorial policy