π What Is shape-image-threshold?
The shape-image-threshold property controls how much of an image's alpha channel (transparency) is used to compute the shape for shape-outside.
It is ONLY used when shape-outside is set to url() or an image-based shape.
In simple words:It determines what parts of an image count as βsolid enoughβ for text to wrap around.
π§© Basic Syntax
Syntax
shape-image-threshold: <number>; /* value between 0 and 1 */
shape-image-threshold: 0; /* loose threshold */
shape-image-threshold: 0.5; /* medium cutoff */
shape-image-threshold: 1; /* strict threshold: only fully opaque pixels count */β Value range: 0 β 1
β Higher value = stricter mask
β Lower value = softer, more inclusive shape
π― How It Works
- 0 β everything with ANY opacity counts (very soft silhouette)
- 1 β only fully opaque pixels count (sharp silhouette)
- Values in between adjust how aggressively transparent areas are removed
π§ͺ Example: Image Shape With Soft Silhouette
Threshold 0 (soft)
.shape-soft {
float: left;
width: 250px;
height: 250px;
shape-outside: url(star.png);
shape-image-threshold: 0;
shape-margin: 10px;
background: url(star.png) center/contain no-repeat;
}β The shape includes even low-opacity areas
β Great for soft glow-like silhouettes
π§ͺ Example: Medium Threshold
Threshold 0.5 (balanced)
.shape-mid {
float: left;
width: 250px;
height: 250px;
shape-outside: url(blob.png);
shape-image-threshold: 0.5;
shape-margin: 10px;
}β Removes lightly transparent pixels
β Good for most PNG artwork with soft edges
π§ͺ Example: Strict Ξ± Cutoff
Threshold 1 (sharp edges)
.shape-strict {
float: left;
width: 250px;
height: 250px;
shape-outside: url(png-shape.png);
shape-image-threshold: 1;
background: url(png-shape.png) center/contain no-repeat;
}β Only 100% opaque pixels define the shape
β Perfect for hard-edged icons or stencils
π Visual Summary
| Threshold | Effect |
|---|---|
| 0 | Very soft edges, almost entire image considered solid |
| 0.5 | Balanced β medium transparency trimmed |
| 1 | Only completely opaque regions used |
π₯ Advanced Example: Creating Clearer Wrapping Around an Irregular Shape
Clear silhouette
.leaf {
float: right;
width: 300px;
height: 300px;
shape-outside: url(leaf.png);
shape-image-threshold: 0.85;
shape-margin: 15px;
}β Removes semi-transparent fringes
β Produces a much cleaner text wrap
π¨ Combining shape-outside + shape-margin + shape-image-threshold
Full combo
.combo {
float: left;
width: 260px;
height: 260px;
shape-outside: url(logo.png);
shape-image-threshold: 0.6;
shape-margin: 20px;
background: url(logo.png) center/contain no-repeat;
}β Smooth control
β Best for image-based wrapping
π οΈ Best Practices
- Use 0β0.4 for soft silhouettes
- Use 0.5β0.8 for balanced shapes
- Use 0.9β1 for crisp shapes (icons, logos)
- Always pair with shape-margin for readability
- Use high-quality PNG/SVG with transparency for best results
β οΈ Browser Support
- β Chrome
- β Safari
- β Edge
- β Firefox does NOT support image shapes (including threshold)
Note
π Debugging Tips
- If text ignores the shape β ensure the element is floated
- Set a fixed width + height on the floated element
- Adjust threshold until the silhouette feels natural
- Check PNG transparency β the alpha channel must exist
- Use a temporary clip-path to visualize shape boundaries