Free tool · technology
CSS Gradient Generator
Build a linear gradient from two colours and copy the CSS.
Colours
Result
- From
- #a3e635
- To
- #0d0f14
- Angle
- 135°
#a3e635
#0d0f14
background: linear-gradient(135deg, #a3e635 0%, #0d0f14 100%);
Runs in your browser · Nothing is uploaded
Embed this on your site
Free to embed. The attribution link stays with the widget, and the calculator keeps working exactly as it does here.
<iframe src="https://thedigitalstash.net/embed/css-gradient-generator" title="The Digital Stash calculator" width="100%" height="720" style="border:0;max-width:100%" loading="lazy"></iframe>
Understanding the CSS Gradient Generator
A CSS gradient is a visual transition between two or more specified colours. The CSS Gradient Generator is a tool designed to produce the necessary code for a linear gradient, which transitions along a straight line from a starting point to an end point. By defining the two colours and the angle of the transition, the tool generates a standard background property that browsers use to render the effect without requiring external image files.
The Method of Gradient Generation
The tool operates by mapping the two selected colours to the linear-gradient CSS function. In its simplest form, a linear gradient requires a direction and at least two colour stops. The generator handles the syntax required for modern browser compatibility.
When you select your colours, the tool places them at the beginning and end of the gradient vector. The space between these two points is filled by the browser through colour interpolation, where it calculates the gradual mathematical shift in red, green, and blue values between the start colour and the end colour. The angle determines the orientation of this line. An angle of 0 degrees points upwards, while 90 degrees points to the right.
A Worked Example
Consider a scenario where a user intends to create a transition from a deep blue to a light grey.
- Selection: The user selects a starting colour of #00008B (DarkBlue) and an end colour of #D3D3D3 (LightGrey).
- Angle Configuration: The user sets the angle of the gradient to 180 degrees. In the CSS coordinate system, this angle directs the gradient from the top of the element towards the bottom.
- Resulting Code: Based on these inputs, the generator produces the following CSS property:
background: linear-gradient(180deg, #00008B, #D3D3D3);
In this example, the browser interprets the 180-degree instruction as a vertical line. It will render the top edge of the designated HTML element as #00008B, smoothly transitioning through the spectrum to reach #D3D3D3 at the bottom edge.
Interpreting the Result
The output provided by the generator is a single line of CSS. This property is intended to be pasted directly into a stylesheet. You should apply this property to the background or background-image attribute of a CSS selector. If you are applying it to a specific element, ensure that the element has a defined height or width. If the element is empty and possesses no dimensions, the gradient will not be visible to the user.
When applying the code, you may find that the gradient appears too compressed or stretched depending on the size of the container. This is a characteristic of the CSS engine, which fits the defined gradient line exactly to the bounding box of the element.
Assumptions and Limits
The tool operates under several technical assumptions:
- Colour Models: The tool assumes the use of hexadecimal colour codes. While CSS supports other formats like RGB or HSL, this generator is limited to hex input for simplicity.
- Linear Transitions: The tool only produces linear gradients. It does not support radial gradients, conic gradients, or repeating patterns.
- Hard-coded Stops: By default, the tool places the start colour at 0% and the end colour at 100% of the gradient line. It does not allow for mid-point adjustments or additional colour stops.
- Browser Support: The generated code relies on the standard W3C linear-gradient syntax. It does not include vendor prefixes for legacy browsers, assuming that the user is working within a modern web environment.
There are physical limits to the display of these gradients as well. Because monitors have a finite number of pixels and a limited colour depth, very subtle gradients may suffer from banding. This occurs when the browser cannot render enough intermediate shades to make the transition appear truly seamless.
Who This Tool Is Not For
This tool is not suitable for users who require complex design capabilities. If your project demands multi-point gradients, intricate opacity adjustments, or non-linear colour easing, a simple two-colour generator will be insufficient.
Furthermore, this tool is not intended for users who are unfamiliar with basic CSS implementation. It does not provide guidance on how to integrate the code into specific content management systems or complex frameworks. If you are looking for a visual editor that manages layers, shadows, or advanced graphical effects, you would be better served by professional-grade design software rather than a utility focused on code output. Finally, it is not for those requiring legacy support for outdated web browsers that do not recognise the standard linear-gradient syntax.
More tools like this
Add Line Numbers
Number every line in a list, with aligned columns for code and checklists.
Run itAge Calculator
Exact age in years, months and days, plus days until the next birthday.
Run itAnagram Checker
Check whether two words or phrases use exactly the same letters.
Run it