Standard CSS borders accept only solid colours.
Loading Gradient…
Generates border-image gradient CSS for standard borders
Outputs pseudo-element technique for rounded-corner borders
Choose gradient direction, colours, and border width
Free tool with instant copy-ready output
Drop the Gradient into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/gradient?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Gradient by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
CSS does not accept gradient function values in the border-color property because border-color is defined to accept only colour values, not image values. Two techniques bridge this gap with different trade-offs. The first uses border-image: set the border-image property to a gradient function and use a slice value of 1 to tell the browser to apply the gradient continuously across the border region. This is the most direct approach and requires minimal CSS. However, it is incompatible with border-radius because the CSS specification defines that border-image overrides and suppresses border-radius clipping on the same element. The second technique uses a pseudo-element as the gradient-filled background, positioned absolutely behind the parent element with a negative z-index and expanded outward by the desired border width using a negative inset value. This method supports border-radius and produces fully rounded gradient borders by setting border-radius: inherit on the pseudo-element.
The border-image technique produces CSS of this form: border: 3px solid transparent; border-image: linear-gradient(90deg, #f093fb, #f5576c) 1. The border declaration establishes the space that the gradient will fill, and the transparent colour is overridden by the border-image. The slice value of 1 after the gradient function is mandatory for continuous gradient rendering. For the pseudo-element technique, the parent element needs position: relative and a solid background colour, and the ::before pseudo-element gets position: absolute; inset: -3px; border-radius: inherit; background: linear-gradient(...); z-index: -1. The parent's solid background colour covers the central area of the pseudo-element, leaving only the outer border-width strip of the gradient visible as the border.
FixTools generates both forms of CSS based on your configuration. For straight-edged elements without border-radius, both methods produce the same visual result and either is appropriate. For elements with border-radius, use only the pseudo-element output, which is the only technique that supports rounded gradient borders in standard CSS without JavaScript.
A third newer technique deserves mention for projects that can adopt modern CSS: the background-origin and background-clip pair allows a single element to render a gradient border without a pseudo-element and with full border-radius support. The pattern uses two stacked backgrounds where the first is the solid interior colour clipped to padding-box, and the second is the gradient clipped to border-box: background: linear-gradient(#fff, #fff) padding-box, linear-gradient(135deg, #667eea, #764ba2) border-box; border: 3px solid transparent. The transparent border declaration reserves the border area, the gradient fills that area through border-box clipping, and the white interior gradient covers everything inside the padding-box. Browser support is universal in current browsers and the markup stays clean with no extra DOM nodes. The trade-off is slightly less obvious syntax for developers unfamiliar with background-clip layering, which is why the pseudo-element approach remains common in teaching examples.
Configure your gradient border colours and width. Example border-image output: border: 3px solid transparent; border-image: linear-gradient(90deg, #f093fb, #f5576c) 1;
Step-by-step guide to css gradient border generator:
Open the CSS Gradient Generator
Navigate to the FixTools CSS Gradient Generator using the link below. The tool opens in visual editing mode with a default gradient configured in the preview. You will configure your gradient colours for the border and then copy the technique-specific CSS output for use in your stylesheet.
Configure your gradient colours
Choose the gradient direction and colour stops you want for the border. For borders, high-contrast gradient pairs tend to read more clearly than subtle tonal gradients because the border is a narrow strip where the full colour spectrum needs to be visible. The preview shows the gradient at full scale to help you judge colour clarity.
Choose the border technique
Select the border-image output for elements without border-radius, such as rectangular data tables, flat-cornered cards, and straight-edged divs. Select the pseudo-element output for any element that uses border-radius, such as rounded cards, pill buttons, rounded input wrappers, or any element where maintaining curved corners is required alongside the gradient border.
Copy and apply the CSS block
Copy the complete CSS block for your chosen technique and apply it to your element class. For the pseudo-element technique, also ensure the parent element has a solid background-color set and position: relative. Without these two properties on the parent, the pseudo-element will not render correctly as a border.
Common situations where this approach makes a real difference:
Feature card with gradient outline
A features grid displays white cards on a white background and needs borders to define card edges without the flatness of a plain grey border. The developer generates a subtle blue-to-purple gradient border using border: 1px solid transparent; border-image: linear-gradient(135deg, #667eea, #764ba2) 1 and applies it to the card element. The gradient border adds brand colour presence to the card edges while keeping the card interior completely clean, creating a premium look that a solid grey border could not achieve.
Rounded input field with gradient focus ring
A design system uses rounded input fields with border-radius: 8px and needs a vivid gradient focus indicator for keyboard accessibility compliance. The developer applies the pseudo-element technique to the input wrapper div: the ::before pseudo-element expands 2px beyond the wrapper using inset: -2px, has a gradient background, and is hidden by default with opacity: 0 and transition: opacity 0.2s. On :focus-within, opacity transitions to 1, revealing the gradient ring with border-radius: 10px. The effect clearly marks focused inputs while satisfying WCAG 2.4.11 focus appearance requirements.
Navigation tab active state
A horizontal tab navigation highlights the currently active tab with a gradient underline that is more distinctive than a flat colour line. The developer applies border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, #f093fb 0%, #f5576c 100%) 1 to the active tab state class. The gradient underline changes colour from left to right, drawing the eye toward the selected tab without visual heaviness. The inactive tabs use either no border-bottom or a neutral grey, making the gradient active state immediately noticeable.
Pricing card highlight border
The recommended plan on a pricing page needs to stand out from the other two cards through a combination of visual signals. The developer wraps the featured card in a container div and applies the pseudo-element gradient border technique with a 2px border and border-radius: 16px matching the card corners. The gradient uses the brand primary and secondary colours. The visible gradient border on the featured card contrasts clearly with the plain grey borders on the other cards, guiding the user's eye toward the recommended option at a glance.
Use this when you want a border that transitions between two or more colours rather than using a flat solid border colour.
Get better results with these expert suggestions:
Use border-image for performance-critical flat-cornered elements
The border-image approach renders in a single layer without requiring any additional DOM elements or pseudo-elements. For tables, data grids, form fields without border-radius, and simple rectangular cards, border-image gradient is the most efficient and maintainable technique. It composes correctly with box-shadow and does not require the parent to have a specific background colour. The CSS is shorter and easier to read, which reduces maintenance overhead when border colours need to change in future design iterations.
Use the pseudo-element technique for any element with border-radius
When border-image is applied to an element that also has border-radius, the specification defines that border-image takes precedence and border-radius is silently ignored. The corners become sharp regardless of the border-radius value, which breaks the design. If your element requires rounded corners and a gradient border together, the pseudo-element technique is the only CSS solution. Set border-radius: inherit on the ::before pseudo-element so it always matches the parent radius without requiring duplicate values that need to be updated together when the corner radius changes.
Set the parent background explicitly for the pseudo-element method
The pseudo-element gradient border works because the parent element has a solid background that covers the central area of the pseudo-element, making only the outer strip visible as the border. If the parent background is transparent or not set, the gradient fills the entire pseudo-element area and appears as a gradient background behind the element content rather than as a border. Always set background: white (or your actual background colour) explicitly on the parent element when using the pseudo-element gradient border technique.
Animate gradient borders with background-position on the pseudo-element
Direct animation of gradient colour stops is not possible in CSS, but the background-position technique works on the pseudo-element. Set background-size: 200% 200% on the ::before pseudo-element and animate background-position using @keyframes from 0% 0% to 100% 100% and back. Because only the outer strip of the pseudo-element is visible as the border, the animated gradient appears to flow around the border edges, producing a dynamic rotating or flowing gradient border animation without any JavaScript or SVG stroke techniques.
More use-case guides for the same tool:
Open the full Gradient — free, no account needed, works on any device.
Open Gradient →Free · No account needed · Works on any device