Border-image-source - CSS Property

border-image-source

Summary of characteristics of the border-image-source property

Quick description
Sets the path and file name for the image used to build the border.
Status
Standard
Predefined values
none
Percentages
Not applicable.
Initial value
none
Inherited by default
No.
Discrète: during an animation, the border-image-source property passes from one value to another without transition. (1)
Single: single value (no order).
W3C Module
CSS Backgrounds and Borders Module
Document status: CR (Candidate Recommendation)

(1) See, however, the special case of certain browsers.

Syntax diagram of border-image-source.

border-image-source - Syntax DiagtramSyntax diagram of the border-image-source CSS property, which defines what image is used for the borders. none none image image gradient gradientborder-image-source:;border-image-source:;
Syntax diagram of the border-image-source property.
The links in the diagram provide more details about the values.
Download the diagram in SVG.

In the diagram, the bold terms are the predefined words of CSS, the other terms are described below:

Description of the border-image-source property.

border-image-source sets the image that will be used to build the border.


Other properties related to image borders.

Shorthand of border properties made with images.
Sets the path and file name for the image used to build the border.
Defines how the border image is clipped.
Sets the thickness of the border when the border is made with an image.
Sets the overflow of the border image.
Defines how the border image is repeated or expanded to cover the desired area.

Values for border-image-source.

  • border-image-source: none;

    Default value. No image will be used for the border.

  • border-image-source: url(...); border-image-source: image(...); border-image-source: image-set(...);

    The specified image will be used for building the border. Many syntaxes allow you to specify the image: refer to the functions url(), image() , image-set() .

  • border-image-source: linear-gradient(...); border-image-source: radial-gradient(...); border-image-source: conic-gradient(...); border-image-source: repeating-linear-gradient(...); border-image-source: repeating-radial-gradient(...); border-image-source: repeating-conic-gradient(...);

    The border will be built from a gradient. Check out the gradient functions for more details on the syntax: conic-gradient() , linear-gradient(), radial-gradient() , and for repeating gradients: repeating-conic-gradient() , repeating-linear-gradient() , repeating-radial-gradient()

  • border-image-source: initial; (none) border-image-source: inherit; border-image-source: revert; border-image-source: revert-layer; border-image-source: revert-rule; border-image-source: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, revert-rule, unset.

Animation of the border-image-source property.

The border-image-source property can be animated. The standard specifies a switch from one image to another without any transition, but some browsers add a fade effect between images. This is the case with Google Chrome or Microsoft Edge, for example.

>

Access the border-image-source property via a program

With Javascript, change the value of border-image-source.

In JavaScript, here's how to change the value of border-image-source. You can see that JavaScript offers a syntax with the typical CSS-style notation, in kebab-case (a dash to separate words), and another syntax with camel-case notation (a capital letter to separate words).

Javascript
let el = document.getElementById('id'); el.style['border-image-source'] = "url('image.png')"; // or let el = document.getElementById('id'); el.style.borderImageSource = "url('image.png')";

With Javascript, read the value of border-image-source.

The property must have been applied directly to the element itself via its style attribute, not through a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['border-image-source']; // or let el = document.getElementById('id'); let value = el.style.borderImageSource;

With Javascript, read the computed value of border-image-source.

The computed value is the one that results from converting relative paths into absolute paths, and from taking into account any inherited values.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('border-image-source');

With JQuery, read or change the value of border-image-source.

JQuery is a JavaScript library that often allows shorter syntax than JavaScript itself.

JQuery

// Read the value:
$('#id').prop('border-image-source');
// Write the value:
$('#id').prop('border-image-source', "url('image.png')");
$('#id').prop('{border-image-source': "url('image.png')"});

With JQuery, read the computed value of border-image-source.

JQuery
let value = $('#id').css('border-image-source');

Other code examples.

Other examples of Javascript and JQuery code are given on the page Javascript and CSS. They all deal with manipulating CSS styles.

Test it yourself.

The buttons below apply the entered value to the border-image-source property and then display either the value as it was applied, or the computed value. This second option lets you see how the value of border-image-source is stored (serialized). In particular, you’ll notice that paths are converted to absolute ones.

Simulator.

border-image-source :

Browsers compatibility with border-image-source.

The border-image-source property and other properties related to border images have been supported from 2015 to 2017 depending on the browsers.

Column 1
Possibility to use images to create borders and, therefore, support for the border-image property.
Column 2
Correct handling by browsers of the property border-image-source which defines the image to be used for the border.

Notes:

(1) Supports the summary property but not detailed properties.

1
Using images
for borders
2
border-image-source
property
Estimated overall support.
97%
95%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Opéra Mobile

Chrome

Edge

Opéra

Safari

Safari sur IOS

Androïd Brower

Chrome pour Androïd

Firefox pour Androïd

Samsung Internet

Firefox

Baidu Browser

QQ Browser

UC Browser pour Androïd

Opéra mini

Historic of the border-image-source property.

  • CSS Backgrounds and Borders Module Level 3

    Level 3 of the specification also explains how to position the background relative to the background area, and how to crop it.
    Regarding borders, the concept of image borders is introduced, as well as the ideas of rounded corners and box shadows.

    Regarding border-image-source Introduction of borders made with an image, instead of simple paths, and corresponding properties, including border-image-width.
    WD
    August 02, 2002
    Working Draft.
    CR
    December 17, 2009
    Candidate Recommendation.
    PR
    REC

Other features of borders and backgrounds.

The properties related to borders, and more specifically to border images, are described in the W3C specification called CSS Backgrounds and Borders Module.

Properties:

background
Summary of background properties.
background-attachment
Background image scrolling mode.
background-clip
Defines the extent of the background, especially in relation to the border and padding.
background-color
Sets the background color.
background-image
Defines the background image or gradient (multiple images or gradients can coexist).
background-origin
Defines a reference to position the background image.
background-position
Defines how the background image is positioned.
background-position-block
Sets the background positioning in the block direction.
background-position-inline
Sets the background positioning along the lines.
background-position-x
Sets how the background image is positioned horizontally.
background-position-y
Defines how the background image is positioned in the vertical direction.
background-repeat
Defines how the background image is repeated.
background-size
Sizing the background image.
border
A shorthand property that defines the set of border parameters: width, style and color.
border-bottom
Sets the parameters of the bottom border of the element (thickness, line style, color).
border-bottom-color
Sets the border line color for the bottom of the element.
border-bottom-left-radius
Sets the radius of the rounded corner at the bottom left.
border-bottom-right-radius
Sets the radius of the rounded corner in the lower right.
border-bottom-style
Sets the line style for the border below the element.
border-bottom-width
Sets the thickness of the border line located below the element.
border-color
Sets the border color for all four sides of the element.
border-end-end-radius
Sets the radius of the corner rounding at the end of line and end of block.
border-end-start-radius
Sets the radius of the corner rounding at the end of line and beginning of the block.
border-image
Langue française
Shorthand of border properties made with images.
border-image-outset
Langue française
Sets the overflow of the border image.
border-image-repeat
Langue française
Defines how the border image is repeated or expanded to cover the desired area.
border-image-slice
Langue française
Defines how the border image is clipped.
Border-image-source
Sets the path and file name for the image used to build the border.
border-image-width
Langue française
Sets the thickness of the border when the border is made with an image.
border-left
Sets the three parameters of the left border of the element (thickness, line style, color).
border-left-color
Sets the color of the left border line of the element.
border-left-style
Sets the border style for the left side of the element.
border-left-width
Sets the thickness of the border on the left side of the element.
border-radius
Radius of rounded corners.
border-right
Sets the three parameters of the right border of the element (thickness, line style, color).
border-right-color
Sets the color of the border line on the right side of the element.
border-right-style
Sets the line style for the right border of the element.
border-right-width
Sets the thickness of the border on the right side of the element.
border-start-end-radius
Sets the radius of the corner rounding at the beginning of the line and the end of the block.
border-start-start-radius
Sets the radius of the corner rounding at the beginning of the line and the beginning of the block.
border-style
Sets the line type for some or all four borders around the element (solid, double, dotted...).
border-top
Sets the parameters of the top border of the element (thickness, line style, color).
border-top-color
Sets the color of the border line above the element.
border-top-left-radius
Sets the radius of the rounded corner at the top left.
border-top-right-radius
Sets the radius of the rounded corner in the upper-right.
border-top-style
Sets the line style for the left border of the element.
border-top-width
Sets the thickness of the border line above the element.
border-width
Sets the thickness of the border line around the element.
box-shadow
Applies a shading effect to the frames by indicating all the parameters: color, shadow shift, blur, etc.