CSS border-image-width Property

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

What You’ll Learn

The border-image-width property controls how wide the sliced border image is painted on each side of an element.

01

Length

px, em, rem.

02

Percentage

Relative sizing.

03

Number

border-width multiplier.

04

auto

Slice intrinsic size.

05

Four Values

Per-side widths.

06

Longhand

Part of border-image.

Definition and Usage

The border-image-width CSS property sets the width of the border image area on each side. After a source image is sliced, this property decides how large those slices appear when painted as the element’s border.

It is a longhand of the border-image shorthand and gives you fine control over decorative borders. You can make a frame thicker or thinner independently of the element’s regular border-width, or let the width follow the slice artwork with auto.

💡
Beginner Tip

border-width reserves space in the layout. border-image-width controls how big the image border looks inside that space. They often match, but they do not have to.

Default vs Custom Width

border-image-width: 1
border-image-width: 20px

📝 Syntax

border-image-width accepts one to four width values:

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

Basic Example

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

Syntax Rules

  • One value applies the same width to all four sides.
  • Two values set vertical sides first, then horizontal sides.
  • Three values set top, horizontal sides, then bottom.
  • Four values follow top, right, bottom, left order.
  • A unitless number multiplies the corresponding border-width on that side.

⚡ Quick Reference

QuestionAnswer
Initial value1
Applies toBorder image painting width
InheritedNo
AnimatableNo
Common useThicker frames, matching slice artwork, asymmetric borders

Default Value

The default value of border-image-width is 1. As a unitless number, it acts as a multiplier of the element’s border-width on each side, so the border image width typically matches the reserved border area.

💎 Property Values

ValueExampleMeaning
Lengthborder-image-width: 20px;Fixed width for the border image on each side
Percentageborder-image-width: 50%;Width relative to the border area size
Numberborder-image-width: 2;Multiplier of the corresponding border-width
autoborder-image-width: auto;Uses the intrinsic width or height of the image slice

Common Value Types

16pxfixed length
22× border-width
autoslice intrinsic size

border-image-width vs related properties

PropertyTargetsBest for
border-image-widthHow wide the border image is paintedControlling frame thickness of sliced artwork
border-widthLayout border area sizeReserving space in the box model
border-image-outsetHow far the border image extends outwardDrawing the border outside the border box
border-imageFull border image shorthandSetting source, slice, width, outset, and repeat together

👀 Live Preview

A box with a 20px border image width:

Uses border-image-width: 20px; with a sliced image source.

Examples Gallery

Try border-image-width with lengths, multipliers, auto, and per-side values.

📚 Basic Width Values

Control how thick the border image appears.

Example 1 — Length Value (20px)

Set a fixed 20px border image width, matching the reference tutorial example.

border-image-width-length.html
<style>
  .border-box {
    width: 300px;
    height: 150px;
    border: 10px solid transparent;
    border-image-source: url("border.png");
    border-image-slice: 30;
    border-image-width: 20px;
  }
</style>

<div class="border-box"></div>
Try It Yourself

How It Works

The border image is painted 20px wide on each side. Because this exceeds the 10px border-width, the image border can extend into the padding area while still using the border box as its reference.

Example 2 — Unitless Number Multiplier

Use 2 to make the border image twice as wide as the corresponding border-width.

border-image-width-number.css
.frame {
  border: 8px solid transparent;
  border-image: url("/images/apple.png") 25 / 2 round;
  padding: 1rem;
  background: #fff;
}
Try It Yourself

How It Works

In the shorthand url(...) 25 / 2, the value after / is border-image-width. With an 8px border, 2 paints a 16px-wide image border.

🎨 auto and Per-Side Widths

Match slice artwork or set different widths on each side.

Example 3 — auto Keyword

Let the browser use the intrinsic size of each border image slice.

border-image-width-auto.css
.card {
  border: 10px solid transparent;
  border-image-source: url("/images/apple.png");
  border-image-slice: 30;
  border-image-width: auto;
  border-image-repeat: round;
  padding: 1rem;
  background: #fff;
}
Try It Yourself

How It Works

auto tells the browser to size each side based on the slice dimensions in the source image, which is useful when your artwork has a natural frame thickness.

Example 4 — Different Width on Each Side

Use four values to set top, right, bottom, and left border image widths separately.

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

How It Works

The values 6px 16px 6px 16px make the top and bottom image borders thinner than the left and right sides, creating an asymmetric frame effect.

🧠 How border-image-width Works

1

Source and slice are set

The border artwork is chosen and divided into regions.

Setup
2

Width values are applied

border-image-width sets how thick each side’s image border is.

Width
3

Slices are painted

Corner and edge regions are drawn at the specified width on each side.

Paint
=

Sized border image

The frame appears at the width you defined on each edge.

Modern Browser Support

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

Baseline · Modern browsers

Border image width in today’s browsers

Length, percentage, number, and auto values all work in current browser versions.

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-width property 96% supported

Bottom line: Use border-image-width to fine-tune frame thickness in modern projects. Test with your actual border artwork and element sizes.

Conclusion

The border-image-width property gives you precise control over how thick a border image appears on each side. Whether you use fixed lengths, multipliers, or auto, it helps you match your frame artwork to the design you want.

Combine it with source, slice, and repeat properties to build decorative borders that go beyond standard solid lines.

💡 Best Practices

✅ Do

  • Start with the default 1 and adjust only when needed
  • Use auto when your slice artwork has a natural frame thickness
  • Set a visible border-width alongside border-image properties
  • Test width values at different element sizes
  • Use the shorthand / syntax in border-image for width

❌ Don’t

  • Confuse border-image-width with border-width
  • Assume a length width always stays inside the border box
  • Forget border-image-source and border-image-slice
  • Use extremely large widths without checking layout impact
  • Mix up border-image-width with border-image-outset

Key Takeaways

Knowledge Unlocked

Five things to remember about border-image-width

Use these points when sizing border images.

5
Core concepts
02

Default 1

Matches border-width.

Default
📏03

px or %

Fixed or relative.

Values
📈04

Number

Width multiplier.

Multiplier
🛠05

auto

Slice intrinsic size.

Keyword

❓ Frequently Asked Questions

The border-image-width property sets how wide the border image is drawn on each side. It can use lengths, percentages, unitless multipliers of border-width, or auto to match slice dimensions.
The initial value is 1, a unitless number that makes the border image width follow the element's border-width on each side.
border-width reserves space in the box model. border-image-width controls how large the sliced border image is painted within that area and can differ from border-width.
The auto keyword uses the intrinsic width or height of the corresponding border image slice from the source artwork.
Yes. You can use one to four values in top, right, bottom, left order, just like border-width shorthand.

Practice in the Live Editor

Open the HTML editor, try border-image-width, and preview sized 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