CSS Portal

CSS Gradient Border Generator

Welcome to the CSS Gradient Border Generator, the fun and easy way to give your web elements a splash of color! Borders don’t have to be boring. With gradients, you can create smooth, vibrant transitions that wrap around buttons, cards, images, or any container, instantly adding a modern, stylish touch to your design.

This tool lets you experiment with multiple colors, adjust the gradient direction, and tweak border thickness - all in real time. As you play with the settings, the CSS code is generated automatically, ready for you to copy and paste into your project.

Transform your elements from plain to playful, subtle to striking, and give your website that professional edge with just a few clicks!

Don't forget to check out our CSS Background Gradient Generator.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!
Gradient Options
  • Orientation
  • Size
  • Position
  • Position
8px
25px
Color Options
  • Start Color
    0%
  • End Color
    100%
Preview
Gradient Border Container
<div class="gradient-border">
  Gradient Border Container
</div>
If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!
Gradient Examples (click to experiment with)

About the CSS Gradient Border Generator

The CSS Gradient Border Generator is designed to make creating colorful, modern borders quick and effortless. With this tool, you can experiment with multiple colors, adjust gradient directions, and set the perfect border thickness-all without writing a single line of code manually.

Whether you’re a web designer looking to add subtle elegance or a developer aiming for bold, vibrant accents, this generator provides the CSS code you need instantly. It’s perfect for buttons, cards, images, and any other elements that deserve a little extra flair.

Our goal is simple: help you bring your web designs to life with gradient borders that are both beautiful and functional.

Why Use Gradient Borders?

  • Modern Aesthetics: Move beyond flat design with subtle glows or vibrant multi-color edges.
  • Visual Hierarchy: Use color transitions to draw attention to call-to-action buttons or featured cards.
  • Brand Consistency: Seamlessly integrate your brand's specific color palette into your site's structural elements.

How It Works

  1. Define Your Colors: Choose two or more colors to create your unique blend.
  2. Adjust the Angle: Rotate the gradient to find the perfect flow for your layout.
  3. Set Border Thickness: Fine-tune the width to achieve anything from a hairline stroke to a bold frame.
  4. Copy & Paste: Grab the generated CSS and drop it directly into your stylesheet.

Frequently Asked Questions

How do you create a gradient border in CSS?

CSS does not allow gradients to be set directly on the border-color property, so gradient borders require a workaround. The most widely used method is to set border: none, apply a background-image with your gradient, and use background-clip: padding-box combined with background-origin: border-box to confine the fill to the padding area while the gradient shows through in the border zone. A cleaner modern approach uses border-image with a gradient value and border-image-slice: 1, though this approach does not support border-radius. For rounded gradient borders, the recommended technique uses a ::before pseudo-element with an absolutely positioned gradient background, placed behind the element using z-index: -1 and inset with a negative margin or padding to simulate the border thickness.

Why doesn't border-image work with border-radius?

This is a known CSS limitation. The border-image property and border-radius are incompatible - when both are applied to the same element, border-radius is ignored and the corners remain square. The browser specification intentionally does not support their combination. If you need both a gradient border and rounded corners, use the ::before pseudo-element technique instead: give the pseudo-element the gradient background, match the border-radius on both the parent and pseudo-element, and use padding on the parent to expose the gradient layer as a visible border.

What is the difference between a linear and radial gradient border?

A linear gradient border transitions colors along a straight line at a defined angle - for example, left to right, top to bottom, or any diagonal. It is the most common choice for gradient borders and suits most buttons, cards, and containers. A radial gradient border radiates colors outward from a central point in a circular or elliptical pattern. This creates a more organic, glowing effect that works well for circular elements or when you want the color to appear to emanate from the centre of the border. Both can use any number of color stops and can repeat using the repeating-linear-gradient or repeating-radial-gradient functions.

Can I animate a CSS gradient border?

CSS cannot directly animate gradient values because gradients are treated as images rather than color values, and browsers cannot interpolate between two gradient images. However, you can achieve animation-like effects using a few workarounds. One approach is to animate the background position on a larger gradient background using background-size and @keyframes, creating the illusion of a moving gradient. Another common technique is to use a conic-gradient rotated via a CSS custom property and a @property registered with @property (Houdini), which allows the angle to be animated smoothly in browsers that support it.

How do I make a gradient border on a button?

The easiest cross-browser approach for a button with a gradient border and a solid fill is to wrap the button in a container that carries the gradient, and set the button's background to match the page background with a small inset. Alternatively, apply the gradient directly to the button using the pseudo-element technique: set position: relative on the button, then add a ::before pseudo-element with position: absolute, a negative inset equal to the desired border width, the gradient as its background, a matching border-radius, and z-index: -1. The button's own solid background then sits on top, leaving only the gradient pseudo-element visible around the edges as the border.

Does CSS gradient border work on all browsers?

The core techniques are well supported across all modern browsers - Chrome, Firefox, Safari, and Edge all handle border-image with gradient values and the pseudo-element approach reliably. The main exception is the @property Houdini approach for animated gradient borders, which is not yet supported in Firefox as of early 2025. For the widest compatibility, the pseudo-element technique with a ::before or ::after layer is the safest choice, as it relies only on standard positioning and background properties that have been supported for many years.

How do I control the thickness of a gradient border?

With the border-image approach, thickness is set using the standard border-width property. With the pseudo-element approach, thickness is controlled by the padding on the parent element (which determines how much of the gradient layer is exposed around the inner content area) or by the negative inset value on the pseudo-element itself. Either way, increasing the value makes the border visually thicker. Most generators, including this one, let you adjust thickness with a slider and reflect the change instantly in the generated code.

Can I use more than two colors in a CSS gradient border?

Yes. CSS gradients support any number of color stops, so you can use three, four, or more colors in a single gradient border. Each color stop can also have a specific position defined as a percentage or length, giving you precise control over where transitions happen. For example, a three-color gradient from red through yellow to blue would be written as linear-gradient(to right, red, yellow, blue). Adding more stops creates richer, more complex transitions - or sharp color bands if you place two stops at the same position.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!