Grow your CSS skills. Land your dream job.

border-image

Last updated on:

The border-image property of CSS allows you to use an image in which to paint the border of an element with.

It's not as straight forward as, say, background-image, which just places the image into the background area. border-image takes the image you give it and slices it like a tic-tac-toe board into nine slices (at the measurements you give it). It then places the corners at the corners, and the middle sections it repeats as needed to fill the element space. The middle section also repeats (or stretches) as you specify.

The individual properties, with their defaults are:

div {
  border-image-source: none;
  border-image-slice: 100%;
  border-image-width: 1;
  border-image-outset: 0;
  border-image-repeat: stretch;
}

Or as shorthand:

div {
  border-image: url("image.png") 25 30 10 20 repeat stretch;
}

Remember that the element needs a border in which to apply this image.

More Information

Related

Browser Support

At the time of this writing, no browser implements un-prefixed. Use -webkit, -moz-, and -o- accordingly.

Chrome Safari Firefox Opera IE Android iOS
7+ 3+ 3.5+ 10.5+ 10- 3.2+ 2.1+

Comments

  1. shshaw
    Permalink to comment#

    This is the weirdest property ever. Such a strange syntax.

    Under More Information, you have Understanding Border Image listed, but there isn’t a link to the article: http://css-tricks.com/understanding-border-image/

    Editors note: thx fixed!

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
    ``` 
    <div>
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
    </div>
    ```
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".