CSS border-image Property

You are Here:

CSS border-image Property

CSS border-image property draws an image in place of an element's border-style. It is a shorthand property of the following CSS properties.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ min-height: 50px; padding-top: 10px; text-align: center; border-width: 50px; border-style: solid; border-image: url("car-left.png") 95% round; } </style> </head> <body> <h1>CSS border-image Property</h1> <div id="point"> border-image: url("car-left.png") 95% round; </div> </body> </html>

Syntax

Using CSS

element{ // border: border-image-source border-image-slice border-image-repeat; border-image: url(car.png) 95% round; }

Using Javascript

object.style.borderImage="url(car.png) 95% round";

Animatable

No, border-image property is not animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS border-image property is none 100% 1 0 stretch.

Property Value

The following table provides a list of values for CSS border-image property.

ValueTypeExplanation
border-image-sourceRequiredSpecifies the path to the image to be used as a border.
border-image-sliceRequiredSpecifies how to divide the border image.
border-image-widthOptionalSpecifies the width of the border image.
border-image-outsetOptionalSpecifies the amount by which the border image area extends beyond the border box.
border-image-repeatRequiredSpecifies how the edge regions of a source image are adjusted to fit the dimensions of an element's border image.

Using JavaScript

In the following example, we will demonstrate how to set the CSS border-image property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ min-height: 50px; padding-top: 10px; text-align: center; border-width: 50px; border-style: solid; border-color: #fff; } </style> </head> <body> <h1>CSS border-image Property</h1> <div> This is div container. </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("div")[0]; function myFunction(){ x.style.borderImage = "url('car-left.png') 95% round"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author