CSS border-image-slice Property

Beginner
⏱️ 7 min read
📚 Updated: Jun 2026
🎯 4 Examples
Box Model & Layout

What You’ll Learn

The border-image-slice property divides a border image into nine regions — four corners, four edges, and a center — so the browser can map each part to the element border.

01

Nine Regions

Corners and edges.

02

Numbers

Image coordinates.

03

Percentages

Relative to image.

04

fill Keyword

Keep center slice.

05

Four Values

Per-side insets.

06

border-image

Longhand property.

Definition and Usage

The border-image-slice CSS property controls how a source image is divided before it is applied as a border. Inset lines are drawn from the top, right, bottom, and left edges of the image, creating nine slices that map to the element’s corners, sides, and optional center.

This property is essential for decorative border artwork. Without slicing, the whole image cannot be reused as a scalable frame. With the right slice values, corners stay crisp while edge sections repeat or stretch along each side.

💡
Beginner Tip

Think of slicing like cutting a picture frame out of one image: corners come from the four corners of the artwork, and the middle strips become the top, right, bottom, and left borders.

The Nine-Slice Grid

Top-leftTop edgeTop-right Left edgeCenterRight edge Bottom-leftBottom edgeBottom-right

📝 Syntax

border-image-slice accepts one to four inset values and an optional fill keyword:

syntax.css
selector {
  border-image-slice: <number> | <percentage>;
}

/* with fill keyword */
selector {
  border-image-slice: 30 fill;
}

Basic Example

border-image-slice.css
.box {
  width: 300px;
  height: 200px;
  border: 10px solid transparent;
  border-image-source: url("border-image.png");
  border-image-slice: 25%;
}

Syntax Rules

  • One value applies the same inset from all four sides of the source image.
  • Two values set vertical insets first, then horizontal insets.
  • Three values set top, horizontal sides, then bottom.
  • Four values follow top, right, bottom, left order.
  • The optional fill keyword keeps the center slice visible inside the element.

⚡ Quick Reference

QuestionAnswer
Initial value100%
Applies toBorder image source division
InheritedNo
AnimatableNo
Common useFrame artwork, decorative image borders

Default Value

The default value of border-image-slice is 100%. That means the inset lines sit at the outer edges of the image, so the full image is used without cutting inward from the sides.

💎 Property Values

ValueExampleMeaning
Numberborder-image-slice: 30;Inset distance from each image edge in image coordinates
Percentageborder-image-slice: 25%;Inset relative to the source image width and height
fillborder-image-slice: 30 fill;Preserves the center slice as the element background
Multiple valuesborder-image-slice: 20 40;Different insets per side using shorthand order

Common Value Types

25%percentage inset
12number inset
20 fillcenter preserved

border-image-slice vs related properties

PropertyTargetsBest for
border-image-sliceHow the source image is dividedCutting frame corners and edges from artwork
border-image-sourceWhich image or gradient to useChoosing the border artwork
border-image-repeatHow edge slices are tiled or stretchedControlling edge appearance after slicing
border-imageFull border image shorthandSetting slice, source, width, outset, and repeat together

👀 Live Preview

A box with a border image sliced at 25% from each edge:

Content inside the box

Uses border-image-source: url("/images/apple.png"); and border-image-slice: 25%;.

Examples Gallery

Try border-image-slice with percentages, numbers, the fill keyword, and per-side values.

📚 Basic Slice Values

Divide the source image evenly or with fixed inset distances.

Example 1 — 25% Slice on All Sides

Slice the border image so each edge region uses 25% of the source image, as in the reference tutorial.

border-image-slice-percent.html
<style>
  .box {
    width: 300px;
    height: 200px;
    border: 10px solid transparent;
    border-image-source: url("border-image.png");
    border-image-slice: 25%;
  }
</style>

<div class="box">
  Content inside the box
</div>
Try It Yourself

How It Works

Each inset line is placed 25% inward from the image edge. The four corner squares become corner borders, and the edge strips map to the top, right, bottom, and left sides.

Example 2 — Numeric Slice Value

Use a unitless number to inset slice lines by a fixed distance in the source image coordinate system.

border-image-slice-number.css
.frame {
  border: 10px solid transparent;
  border-image: url("/images/apple.png") 30 round;
}
Try It Yourself

How It Works

In the shorthand url(...) 30, the number 30 is the slice value. It cuts 30 units inward from each edge of the source image.

🎨 fill and Per-Side Slices

Preserve the center region or use different insets on each side.

Example 3 — Slice with fill Keyword

Compare the same slice with and without fill. Without it, the center slice is discarded and the element background shows through. With fill, the center region is painted inside the border.

border-image-slice-fill.css
.box {
  border: 10px solid transparent;
  border-image-source: linear-gradient(to bottom, #2563eb 30%, #fef08a 30% 70%, #7c3aed 70%);
  border-image-slice: 25%;
  background: #fff;
}

/* keep the center slice visible */
.box.with-fill {
  border-image-slice: 25% fill;
}
Try It Yourself

How It Works

The source gradient has a yellow middle band. Slicing at 25% cuts that band as the center region. Without fill, it is thrown away and you see the white background. With fill, the yellow center slice is painted inside the border.

Example 4 — Different Slice on Each Side

Use four values to control top, right, bottom, and left insets separately.

border-image-slice-sides.css
.panel {
  border: 8px solid transparent;
  border-image-source: repeating-linear-gradient(45deg, #2563eb 0 8px, #fff 8px 16px);
  border-image-slice: 10 20 10 20;
  border-image-repeat: round;
  padding: 1rem;
  background: #fff;
}
Try It Yourself

How It Works

The values 10 20 10 20 inset the top and bottom by 10 and the left and right by 20 in the source coordinate system, creating asymmetric corner and edge regions.

🧠 How border-image-slice Works

1

You provide a source image

Set border-image-source to an image URL or gradient.

Source
2

Slice insets divide the image

border-image-slice cuts the image into nine regions.

Slice
3

Regions map to the border

Corners and edges are placed on the matching sides of the element border box.

Mapping
=

Image-based frame border

Your element gets a decorative border built from sliced image regions.

Modern Browser Support

The border-image-slice property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

Border image slicing in today’s browsers

Chrome, Edge, Firefox, Safari, and Opera support border-image-slice including the fill keyword.

96% Modern browser support
Google Chrome15+ · Desktop & Mobile
Full support
Mozilla Firefox15+ · Desktop & Mobile
Full support
Apple Safari6+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera15+ · Modern versions
Full support
border-image-slice property 96% supported

Bottom line: Use border-image-slice for image frame borders in modern projects. Test slice values with your actual artwork dimensions.

Conclusion

The border-image-slice property is the key to turning one image into a reusable border frame. By choosing the right inset values and optionally using fill, you can create unique decorative borders that go far beyond simple lines.

Experiment with percentages, numbers, and per-side values to see how slicing changes the look of your border artwork on different element sizes.

💡 Best Practices

✅ Do

  • Design border artwork with clear corner and edge regions
  • Start with equal percentage slices like 25% for symmetric frames
  • Use fill when the center art should show inside the box
  • Test slice values at different element sizes
  • Combine with border-image-repeat: round for tiled edges

❌ Don’t

  • Assume unitless numbers are CSS pixels on the element
  • Use slice values larger than half the image width or height on opposite sides
  • Forget to set border-image-source and a visible border width
  • Expect slice to work without a raster or gradient source
  • Use tiny slice values on high-resolution artwork without testing

Key Takeaways

Knowledge Unlocked

Five things to remember about border-image-slice

Use these points when dividing border image artwork.

5
Core concepts
02

Default 100%

Full image used.

Default
📏03

% or Number

Inset distances.

Values
🖼️04

fill

Keep center art.

Keyword
🛠05

Needs source

Part of border-image.

Usage

❓ Frequently Asked Questions

The border-image-slice property divides a border image into nine regions — four corners, four edges, and a center — by specifying inset distances from each side of the source image.
The initial value is 100%, which uses the entire image without inset slicing from the edges.
The fill keyword keeps the center slice visible and uses it as the element background area inside the border.
Unitless numbers are coordinates measured from the source image edges in the image's own coordinate system, not the element's CSS pixel size.
Yes. You can use one to four values in top, right, bottom, left order, or percentages relative to the image width and height.

Practice in the Live Editor

Open the HTML editor, try border-image-slice, and preview sliced border frames instantly.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful