CSS Portal

CSS border-image Property

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

Description

The border-image property lets you use an image to draw an element’s border instead of (or in addition to) the conventional color-based border. Conceptually the source graphic is divided into regions - corners and edge strips - and those regions are used to paint the corresponding parts of the box’s border. This allows designers to create decorative frames, skinned UI components, or complex edge treatments that scale to different box sizes while preserving corner detail and edge patterns.

The image is cut into nine logical areas (four corners, four edges, and the center). The corner pieces are typically preserved to keep their shape; the edge strips are then stretched, tiled, or otherwise adapted to span the side lengths between corners. Because the image replaces the visual border, it works together with the element’s existing border properties: the element must have a visible border style for the image to be rendered, and the border’s widths determine how much space the image occupies along each side. For reference to the standard border mechanics, see border and border-style.

Beyond edges and corners, the source image also has a central region that may be used to fill the area inside the border or left out entirely depending on how the image is intended to behave. The way the image is scaled and positioned interacts with the element’s background painting - the border-image sits around the content and will visually combine with any background artwork - so you should consider how the frame image and the element’s background will layer together. See background for how background content relates to box painting. Rounded corners on the element will also affect how the image is clipped and rendered, so plan corner artwork with the box’s corner radii in mind; for details on corner shaping see border-radius.

In practical use, designers create images specifically for this technique (often called nine-slice or scalable frames) so that corners remain crisp while edges scale or repeat naturally. Use suitably high-resolution artwork if the border must scale up, and test how the image behaves at different box sizes to avoid unwanted distortion. For debugging and fallbacks, keep a simple solid border style available so the component still looks acceptable if the image fails to load or the border-image behavior is not desired in certain contexts.

Definition

Initial value
See individual properties
Applies to
All elements
Inherited
No
Computed value
See individual properties
Animatable
See individual properties
JavaScript syntax
object.style.borderImage

Interactive Demo

Example of the border-image property.

Syntax

border-image: <border-image-source> || <border-image-slice> [ / <border-image-width> | / <border-image-width>? / <border-image-outset> ]? || <border-image-repeat> 

Values

Example

<div class="card">
<h1>Border Image Card</h1>
<p>This card uses border-image with a gradient and rounded corners.</p>
</div>
/* Reset and center */
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background: #f5f7fb;
}

/* Card with border-image */
.card {
    width: 320px;
    padding: 24px;
    border: 16px solid transparent;
    border-radius: 12px;
    border-image-source: linear-gradient(135deg, #ff7a18, #af002d 50%, #321575 100%);
    border-image-slice: 1;
    border-image-repeat: round;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(50, 50, 93, 0.12);
    text-align: center;
}

.card h1 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #222;
}

.card p {
    margin: 0;
    color: #555;
    font-size: 14px;
}

Browser Support

The following information will show you the current browser support for the CSS border-image property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

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