Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

CSS border-image Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The border-image property in CSS is used to set the border of an element.

Syntax:

border-image: source slice width outset repeat|initial|inherit;

The border-image property is the combination of many properties which are listed below:

  • border-image-source
  • border-image-slice
  • border-image-width
  • border-image-outset
  • border-image-repeat

Property Values:

  • border-image-source: This property is used to set the source location of border image.
    Syntax:

    border-image-source: url(image source location);
  • border-image-slice: The border-image-slice property is used to divide or slice an image specified by border-image-source property.
    The border-slice property divides a given image into:

    • 9 regions
    • 4 corners
    • 4 edges
    • A middle region

    Syntax:

    border-image-slice: value;
  • border-image-width: The border-image-width property is used to set the width of the border.

    Syntax:

    border-image-width: value;
  • border-image-outset: The border-image-outset property sets the distance by which an element border image is set out from its border box.
    Syntax:

    border-image-outset: value;
  • border-image-repeat: The border-image-repeat property defines how the edge regions of the source image are adjusted to fit the dimensions of an element border image.
    Syntax:

    border-image-repeat: value;
  • initial: It is used to set border-image property to its default value.
  • inherit: It is used to set border-image property from its parent.

Example 1:




<!DOCTYPE html>
<html>
    <head>
        <title>
            CSS border-image Property
        </title>
          
        <style>
            #borderimg1 {
                border: 10px solid transparent;
                padding: 15px;
                -webkit-border-image: url(
                30 round;
                border-image: url(
                30 round;
                text-align:center;
            }
  
            #borderimg2 {
                border: 10px solid transparent;
                padding: 15px;
                -webkit-border-image: url(
                30 stretch;
                border-image: url(
                30 stretch;
                text-align:center;
            }
        </style>
    </head>
      
    <body>
        <h2>border-image property</h2>
          
        <p id = "borderimg1">
            Element Content
        </p>
        <p id = "borderimg2">
            Element Content
        </p>
    </body>
</html>                    

Output:

Example 2:




<!DOCTYPE html>
<html>
    <head>
        <title>
            CSS border-image Property
        </title>
          
        <style>
            #borderimg1 {
                border: 15px solid transparent;
                padding: 15px;
                border-image:url(
                50 round;
            }
  
            #borderimg2 {
                border: 15px solid transparent;
                padding: 15px;
                border-image:url(
                40% stretch;
            }
            #borderimg3 {
                border: 15px solid transparent;
                padding: 15px;
                border-image:url(
                70 round;
            }
        </style>
    </head>
      
    <body>
        <h2>border-image property</h2>
        <p id = "borderimg1">BORDER 1</p>
        <p id = "borderimg2">BORDER 2</p>
        <p id = "borderimg3">BORDER 3</p>
    </body>
</html>                    

Output:

Supported Browsers: The browser supported by border-image property are listed below:

  • Google Chrome 16.0, 4.0 -webkit-
  • Internet Explorer 11.0
  • Firefox 15.0, 3.5 -moz-
  • Opera 15.0, 11.0 -o-
  • Safari 6.0, 3.1 -webkit-

My Personal Notes arrow_drop_up
Last Updated : 01 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials