CSS geometry
The border can have a shape, too
Content and border share the same contour.
Draw non-rectangular borders with basic shapes and shape(), compare stroke and fill modes, and see the border follow the geometry.
CSS geometry
Content and border share the same contour.
This browser does not support border-shape yet. The preview uses an approximate clip-path fallback; a shaped border requires native support.
<article class="border-shape" aria-labelledby="border-shape-title">
<p>CSS geometry</p>
<h2 id="border-shape-title">The border can have a shape, too</h2>
<p>Content and border share the same contour.</p>
</article><article class="box-border w-full max-inline-md min-w-0 min-block-72 p-[min(3rem,10%)] wrap-anywhere text-center bg-[#172033] border-7 border-solid border-[#f97316] text-slate-50 [clip-path:polygon(2%_2%,_calc(100%_-_2%)_2%,_calc(100%_-_2%)_calc(100%_-_2%_-_24px),_calc(62%_+_24px)_calc(100%_-_2%_-_24px),_62%_calc(100%_-_2%),_calc(62%_-_24px)_calc(100%_-_2%_-_24px),_2%_calc(100%_-_2%_-_24px))_border-box] supports-[border-shape:circle(50%)]:[clip-path:none] supports-[border-shape:circle(50%)]:[border-shape:shape(_from_calc(2%_+_17px)_2%,_hline_to_calc(100%_-_2%_-_17px),_curve_to_calc(100%_-_2%)_calc(2%_+_17px)_with_calc(100%_-_2%)_2%,_vline_to_calc(100%_-_2%_-_24px_-_17px),_curve_to_calc(100%_-_2%_-_17px)_calc(100%_-_2%_-_24px)_with_calc(100%_-_2%)_calc(100%_-_2%_-_24px),_hline_to_calc(62%_+_24px),_line_to_62%_calc(100%_-_2%),_line_to_calc(62%_-_24px)_calc(100%_-_2%_-_24px),_hline_to_calc(2%_+_17px),_curve_to_2%_calc(100%_-_2%_-_24px_-_17px)_with_2%_calc(100%_-_2%_-_24px),_vline_to_calc(2%_+_17px),_curve_to_calc(2%_+_17px)_2%_with_2%_2%,_close_)_border-box]" aria-labelledby="border-shape-title">
<p>CSS geometry</p>
<h2 id="border-shape-title">The border can have a shape, too</h2>
<p>Content and border share the same contour.</p>
</article>@supports (border-shape: circle(50%)) {
.border-shape {
border-shape: shape(
from calc(2% + 17px) 2%,
hline to calc(100% - 2% - 17px),
curve to calc(100% - 2%) calc(2% + 17px) with calc(100% - 2%) 2%,
vline to calc(100% - 2% - 24px - 17px),
curve to calc(100% - 2% - 17px) calc(100% - 2% - 24px) with calc(100% - 2%) calc(100% - 2% - 24px),
hline to calc(62% + 24px),
line to 62% calc(100% - 2%),
line to calc(62% - 24px) calc(100% - 2% - 24px),
hline to calc(2% + 17px),
curve to 2% calc(100% - 2% - 24px - 17px) with 2% calc(100% - 2% - 24px),
vline to calc(2% + 17px),
curve to calc(2% + 17px) 2% with 2% 2%,
close
) border-box;
}
}
.border-shape {
box-sizing: border-box;
inline-size: min(100%, 28rem);
min-inline-size: 0;
min-block-size: 18rem;
padding: min(3rem, 10%);
overflow-wrap: anywhere;
text-align: center;
background-color: #172033;
border: 7px solid #f97316;
color: #f8fafc;
}
@supports not (border-shape: circle(50%)) {
.border-shape {
clip-path: polygon(2% 2%, calc(100% - 2%) 2%, calc(100% - 2%) calc(100% - 2% - 24px), calc(62% + 24px) calc(100% - 2% - 24px), 62% calc(100% - 2%), calc(62% - 24px) calc(100% - 2% - 24px), 2% calc(100% - 2% - 24px)) border-box;
}
}.border-shape {
@supports (border-shape: circle(50%)) {
border-shape: shape(
from calc(2% + 17px) 2%,
hline to calc(100% - 2% - 17px),
curve to calc(100% - 2%) calc(2% + 17px) with calc(100% - 2%) 2%,
vline to calc(100% - 2% - 24px - 17px),
curve to calc(100% - 2% - 17px) calc(100% - 2% - 24px) with calc(100% - 2%) calc(100% - 2% - 24px),
hline to calc(62% + 24px),
line to 62% calc(100% - 2%),
line to calc(62% - 24px) calc(100% - 2% - 24px),
hline to calc(2% + 17px),
curve to 2% calc(100% - 2% - 24px - 17px) with 2% calc(100% - 2% - 24px),
vline to calc(2% + 17px),
curve to calc(2% + 17px) 2% with 2% 2%,
close
) border-box;
}
box-sizing: border-box;
inline-size: min(100%, 28rem);
min-inline-size: 0;
min-block-size: 18rem;
padding: min(3rem, 10%);
overflow-wrap: anywhere;
text-align: center;
background-color: #172033;
border: 7px solid #f97316;
color: #f8fafc;
@supports not (border-shape: circle(50%)) {
clip-path: polygon(2% 2%, calc(100% - 2%) 2%, calc(100% - 2%) calc(100% - 2% - 24px), calc(62% + 24px) calc(100% - 2% - 24px), 62% calc(100% - 2%), calc(62% - 24px) calc(100% - 2% - 24px), 2% calc(100% - 2% - 24px)) border-box;
}
}Educational guide to border-shape
A border can follow a diamond or a curve. Learn to separate contour, reference box and content, compare one and two shapes, and keep a readable base when support is missing.
Layout calculates a box; border-shape changes how its border is painted.
Dimensions, padding and border-width still reserve rectangular space.
A geometric function resolves against a reference box.
One shape produces a stroke; two bound the region to fill.
border-shape enables nonrectangular borders with circle(), ellipse(), polygon(), path() or shape(). Its initial value is none. It does not rearrange text lines to follow the silhouette: content keeps its rectangular flow.
With a single shape, border-width determines stroke thickness.
These two samples use the same polygon() from the lab generator. Only border-width changes: 4px versus 12px. The stroke is centered on the path; border-box is explicit here and the vertices are inset to leave room for the stroke.
Native syntax available for this example.
Rectangular fallback: this border-shape syntax is unavailable.
Without an explicit box, one shape uses half-border-box: the path runs through the middle of the conventional border. These examples use a uniform solid border; with different sides, the specification takes the first side whose style is not none in logical order: block-start, inline-start, block-end, inline-end.
The first contour bounds the outside; the second defines the inner opening.
Write two shapes separated by a space, without a comma. The border fills the region between them using border-color. Both samples fix both contours against border-box: changing border-width no longer changes those explicit paths, although it still affects layout.
Native syntax available for this example.
Rectangular fallback: this border-shape syntax is unavailable.
Without explicit boxes, the outer contour uses border-box and the inner one padding-box; border-width then also changes the inner reference. Two different percentages do not guarantee constant thickness perpendicular to the contour. Keep the inner shape inside the outer one and check the actual size.
The same function can produce different paths depending on where it is measured.
border-box includes the border; padding-box excludes it; content-box also excludes padding. In these samples, inset(0) follows the boundary of each reference. The dashed outer box belongs to the wrapper so you can compare the path with the reserved rectangular space.
Native syntax available for this example.
Rectangular fallback: this border-shape syntax is unavailable.
Percentages resolve according to the function and its box: for example, circle() does not treat its percentage radius as simply half the width. For a predictable circle, test the box proportions too. path() uses its path coordinates; shape() allows adaptable lengths and percentages. Check each combination, not just the property name.
Clipping a box and painting a shaped border solve different problems.
clip-path hides everything outside its region: it also cuts the existing rectangular border, shadows and content. It does not create a border along the diagonals. border-shape defines the border path itself; outline and box-shadow can follow that shape according to their support.
Native syntax available for this example.
Rectangular fallback: this border-shape syntax is unavailable.
Choose clip-path to hide part of an image or surface; border-shape to define a border. An approximate clip-path can be a visual alternative, but it is not equivalent to a shaped border and can clip focus or information. This guide uses a rectangle as its base; the existing playground explicitly identifies its approximate clip-path fallback.
Reserve space for reading before adjusting a silhouette.
The visual inner region does not change text flow. Avoid enclosing paragraphs in a fixed-height diamond. This note cuts only a 1rem corner and reserves 1.5rem padding, with no fixed height, so content can grow when text is enlarged.
This note preserves its text when the window narrows or the font grows. Padding separates the lines from the border; the shape does not rearrange them.
Native syntax available for this example.
Rectangular fallback: this border-shape syntax is unavailable.
overflow remains a separate decision: when overflow is clipped, the inner contour contributes to the clipping area. Do not use overflow: hidden or clip-path as an automatic fix for text that does not fit. If you add links or buttons, check Tab, visible focus, hit areas and forced colors. border-radius and corner-shape do not combine to round border-shape: with a value other than none, their corners are ignored.
Check painting, references and reading separately.
An experimental property needs a useful base and syntax-specific detection.
Checked on October 22, 2026: limited availability. Web Platform DX and MDN BCD record Chrome/Edge from 147 and no stable support in Firefox/Safari. The general card does not certify every function, box or interaction.
Each recipe keeps border outside @supports and enables the enhancement with its specific value. Notices switch through CSS, including without JavaScript. @supports checks syntax acceptance, not painting quality, contrast or accessibility. Check the result in target browsers and revisit the sources before publishing.