Skip to main content

CSS Border Image Generator

API reference

Generate CSS border-image code from a gradient, a built-in pattern or your own image — set slice, width, outset, repeat and fill with a live preview, then copy the CSS and HTML.

Input

Pushes the border image outside the element's border box.

How the edge slices fill each side: stretched, tiled, tiled and scaled to fit, or tiled with even gaps.

Adds the fill keyword so the center slice paints the element's background.

Only used for the preview and HTML snippet.

Output

Your framed box will appear here.

border-image declarations
 
CSS
 
HTML
 
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/css-border-image-generator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": "gradient",
    "color1": "#6366f1",
    "color2": "#ec4899",
    "angle": "135",
    "width": "15",
    "outset": "0",
    "repeat": "stretch",
    "fill": "",
    "text": "Framed content",
    "boxColor": "#ffffff",
    "bgColor": "#f1f5f9"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `css-border-image-generator` tool (CSS Border Image Generator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/css-border-image-generator/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="CSS Border Image Generator — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

The CSS border-image property paints an element's border with an image or a gradient instead of a flat color. It cuts the source into nine pieces (four corners, four edges and a middle) and stretches or tiles them around the box. This generator builds the full declaration from a gradient, a built-in pattern or your own image, and shows the result live as you adjust it.

How to use it

  1. Pick an image source.
    • Gradient uses a linear-gradient() as the source. It is the simplest way to get a gradient border. Choose two colors and an angle.
    • Pattern uses one of five built-in tiles: checker, stripes, dots, diamonds or a double-line frame. The tile is inlined as an SVG data URI, so the CSS works with no extra file.
    • Image URL uses your own https:// image. Set Slice to the size of the image's corners in pixels.
  2. Set the border width. This is both the border width and the border-image-width.
  3. Adjust the outset to push the image outside the box without changing its layout.
  4. Choose how edges repeat: stretch, repeat, round (tiles scaled to fit a whole number of times) or space (whole tiles with even gaps).
  5. Turn on "Fill the middle" to add the fill keyword, which paints the center slice over the element's background.
  6. Copy the output. You get the declarations (shorthand plus longhand equivalents), a complete CSS rule and a matching HTML snippet.

How border-image-slice works

border-image-slice sets how far in from each edge of the source image the cuts are made. A slice of 30 on a 90×90 image gives nine 30×30 pieces: the corners stay as they are and the edges are stretched or tiled along each side. Gradients have no fixed size, so gradient borders use a slice of 1.

Common gotchas

  • The border needs a style. border-image only draws when border-style is set. The generated code always includes border: <width> solid <color>, and that color also acts as a fallback.
  • border-radius has no effect. A border image ignores rounded corners. For a rounded gradient border, use a background-clip technique or a mask instead.
  • Outset does not take up space. It can overlap nearby content, so leave room with margin or padding.

For zigzag, wavy or scalloped edges, try the CSS Border Style Generator. To round the corners of a plain border, use the Border Radius Generator. For focus rings, see the CSS Outline Generator.

Privacy

Everything runs in your browser. Your settings are never uploaded. If you use an image URL, your browser loads that image directly to draw the preview.

border-imageborder-image-sliceborder-image-repeatgradient border9-sliceimage borderdecorative framecss frame

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.