The border-image property replaces the standard border color with any image, including SVGs, PNGs, and CSS gradients.
Loading Border Builder…
Configure border-image-source, slice, repeat, and width
Live preview of image slicing across border corners and edges
Supports gradient sources and external image URLs
Generates complete border-image shorthand declaration
Drop the Border Builder 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/border-builder?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Border Builder by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
Border-image-source sets what image the border uses. It accepts any CSS image value: url() for external files, linear-gradient(), radial-gradient(), conic-gradient(), or element() for live element captures. The image is then divided into nine regions by border-image-slice. The four corner regions paint the border corners; the four edge regions tile or stretch along each border side; the center region is discarded by default unless you add the fill keyword. For a simple gradient border, the source is the gradient and the slice is 1, which tells the browser to use 1 pixel from each edge as the cutting boundary.
Border-image-slice is the most misunderstood part of border-image. It accepts one to four values that define how many pixels (or what percentage of the image) to slice from each edge. For a 90x90px SVG image border, border-image-slice: 30 cuts 30px from each edge, leaving a 30x30px center. The 30px corner regions go to the four corners; the remaining edge strips tile or stretch across each side. For raster images designed as border frames, the slice values correspond to the visual corner size in the image. For gradients, slice: 1 works universally because a 1-unit slice from a generated gradient captures the color information correctly.
Border-image-repeat controls how edge regions fill the border sides between corners. Stretch is the default and scales the edge strip to fill the entire side without repetition. Round tiles the edge region and resizes the tiles to fit without partial tiles at the ends. Space also tiles but adds spacing between tiles rather than resizing them. Repeat tiles the edge strip without adjustment, which may produce partial tiles at the ends. For decorative SVG borders with pattern edges, round is usually the best choice. For gradient borders, stretch is always correct because gradients scale without visible artifacts.
Border-image and clip-path occupy adjacent but non-overlapping territory in CSS, and choosing between them depends on what you sacrifice. Border-image paints an image inside the element's border region while leaving the content area, focus ring, and box-shadow behaviour intact. Clip-path produces non-rectangular shapes (hexagons, arrows, speech bubbles) that border-image cannot reach, but at the cost of losing the visible border outline, the box-shadow rendering, and the default focus indicator that browsers draw via outline. For any shape that can be expressed as a rectangle with possibly rounded corners, border-image with a gradient or SVG source is the right tool because it preserves accessibility and layered rendering. Reach for clip-path only when the shape genuinely cannot be expressed with border-radius, and be prepared to reconstruct shadows (via filter: drop-shadow on a wrapping element) and focus indicators (via a sibling or pseudo-element) by hand. The combined complexity is usually higher than designers expect.
Enter a gradient or image URL as the source, set slice to 1 for gradients or 30% for raster images, and choose stretch or round for repeat. Set border-width to 4px or higher to see the border-image clearly. Adjust slice values to control corner versus edge regions.
Step-by-step guide to css border-image generator:
Set the border-image source
Enter a gradient function or image URL. For gradients, use linear-gradient() with your colors. For raster images, use url() with an absolute path or hosted URL.
Configure border-image-slice
For gradients, set slice to 1. For raster images, set slice to the corner region size in pixels (matching the corner decoration size in your image).
Choose border-image-repeat
Select stretch for gradients and smooth textures. Use round for patterned edge regions that need complete tiles. The preview shows how each option looks on the element.
Set border-width
Set border-width to the visual border thickness you want. For image borders, 4px to 20px is common depending on the decoration. Ensure border-style is set to solid to activate the border area.
Common situations where this approach makes a real difference:
Gradient border on a pricing card
A featured pricing plan card uses border-image: linear-gradient(135deg, #6366f1, #ec4899) 1 with border-width: 2px to display a gradient border. The gradient transitions from indigo to pink, creating a colorful accent that distinguishes the featured card from the standard bordered cards. Setting border-radius alongside border-image is not supported, so this technique works best on flat-cornered cards.
SVG ornamental frame border
A certificate or award template uses an SVG ornamental border image. The SVG is designed with decorated corners and plain edges. Setting border-image: url(ornament-border.svg) 60 round allocates 60px to each corner region and tiles the edge regions with the round mode to avoid partial patterns. This creates a scalable decorative frame that works at any certificate size.
Progress indicator border on a loading card
A data loading card shows progress using border-image: linear-gradient(to right, #6366f1 var(--progress), #e5e7eb var(--progress)) 1 where --progress is a CSS custom property updated by JavaScript. At 0%, the border is all gray. At 100%, it is all indigo. The transition between states animates with CSS transition on the custom property if registered with @property.
Striped pattern border using repeating gradients
A construction-style warning pattern uses border-image: repeating-linear-gradient(45deg, #f59e0b 0, #f59e0b 10px, #000 10px, #000 20px) 20 round as a border. The 45-degree diagonal stripes alternate between amber and black at 10px intervals. Setting border-width: 20px makes the stripes clearly visible. This pattern is used for draft-mode indicators and blocked content placeholders.
Get better results with these expert suggestions:
Use SVG borders for scalable decorative frames
SVG files scale without pixelation, making them ideal for border-image sources on elements of varying sizes. A corner-decorated SVG frame border stays crisp at any element size. Design the SVG at a standard size like 90x90px with 30px corners, then set border-image-slice: 30 and border-image-width: 30px. The SVG corners render at full quality at any resolution.
Border-image-outset extends the border outside the element box
Setting border-image-outset: 4px expands the rendered border image 4px beyond the element's border box in all directions. The border occupies space in the overflow area rather than the layout flow, similar to how a negative outline-offset works. This is useful for decorative frames or glowing borders that should appear larger than the physical border-width.
Test border-image on different element aspect ratios
Edge regions stretch or tile to fill the border sides, which means the appearance of patterned borders changes with the element's aspect ratio. Test your border-image on both wide and tall elements to confirm the edge regions look correct in both orientations. Some patterns that look fine on a square element become distorted on a very wide or very tall element.
Use border-image to create a progress bar style border
A linear-gradient that covers only part of the border length can simulate a partial-fill progress border. Setting border-image: linear-gradient(to right, #6366f1 60%, #e5e7eb 60%) 1 paints the gradient at 60% indigo and 40% gray, creating a progress indicator on the border. Updating the percentage via JavaScript simulates progress animation.
Design SVG border images at 3x the corner size
When creating an SVG for use as a border image, make the canvas size at least 3x the intended corner size in each dimension. A 90x90px SVG with a 30px border means each corner region is 30x30px, giving enough detail for the corner decoration. Set border-image-slice to 30 to match.
Use border-image-width to override border-width for painting
Border-image-width sets the painted width of the border image independently of border-width. Setting a larger border-image-width stretches the image into the content or padding area. This is distinct from border-width, which controls layout space allocation. Use border-image-width when the visual weight of the image border needs to differ from the space allocated for it.
Add fill to show the center region
By default, border-image discards the center region of the sliced image. Adding fill to border-image-slice causes the center to paint over the element's background. This is useful for image-framed content boxes where the frame design includes a center texture or color that should fill the content area.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full Border Builder — free, no account needed, works on any device.
Open Border Builder →Free · No account needed · Works on any device