Breaking away from stacked horizontal rectangles makes marketing pages, documentation callouts, and feature transitions feel bespoke—when engineered cleanly. Historically, non-rectangular boundaries required slicing transparent PNG edges that broke on wide screens. Today, browsers give us three native tools: clip-path, mask-image, and inline <svg> dividers.
Picking the right primitive avoids clipped drop-shadows, broken hit-testing, and 1-pixel mobile zoom seams. Test both polygon and curved approaches interactively in our CSS Clip-Path & SVG Blob Maker and SVG Wave Maker.
1. Choosing Between clip-path, mask-image, and Inline <svg>
| Capability | CSS clip-path |
CSS mask-image |
Inline <svg> Divider |
|---|---|---|---|
| Edge Softness | Hard crisp vector edge only | Supports soft alpha & gradient fades | Crisp vector curves & layered opacity |
| Extra HTML Markup | Zero (pure CSS property) | Zero (pure CSS property) | 1 lightweight <svg> block (~500 B) |
| Pointer Hit-Testing | Clipped region ignores clicks | Masked-out region still receives clicks! | Standard DOM element bounds |
| Best Use Case | Slanted sections, chamfered cards, hexagons | Fading grids, soft image vignettes | Multi-layer organic Bezier waves |
Watch Out for Hit-Testing:
clip-pathupdates the browser's pointer hit-test geometry (clicks on clipped-out corners pass through to elements underneath), whereasmask-imageis purely visual—invisible masked pixels still intercept mouse clicks unlesspointer-events: noneis applied!
2. Responsive Angle Math with calc() Inside clip-path: polygon()
Using pure percentages like polygon(0 0, 100% 0, 100% 85%, 0 100%) makes a hero slant steep on tall mobile screens and flat on wide monitors. Using calc(100% - 4vw) ties the slant height directly to viewport width so the geometric angle stays identical across every screen size:
.slanted-section {
background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
padding-bottom: calc(4rem + 4vw);
clip-path: polygon(
0 0,
100% 0,
100% calc(100% - 4vw),
0 100%
);
}
3. Preserving Borders & Drop Shadows Around Clipped Cards
Because clip-path trims everything painted by the element—including border and box-shadow—chamfered cards need either a wrapper filter: drop-shadow() (for soft elevation) or a layered 1px inset child (for crisp hairline borders):
<!-- Wrapper paints drop-shadow around the clipped chamfered silhouette -->
<div class="drop-shadow-[0_8px_20px_rgba(15,23,42,0.08)]">
<div
class="bg-slate-300 p-[1px]"
style="clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);"
>
<div
class="bg-white p-6"
style="clip-path: polygon(0 0, calc(100% - 19.5px) 0, 100% 19.5px, 100% 100%, 0 100%);"
>
<h3 class="font-bold text-slate-900">Chamfered Technical Card</h3>
<p class="text-sm text-slate-600">Crisp 1px border + soft shadow with zero SVG files.</p>
</div>
</div>
</div>
For rectangular surface depth without clipping, see Layered CSS Box-Shadows & Elevation Systems.
4. Modern clip-path: path() & shape() vs. Percentage polygon()
For years, CSS clip-path faced an annoying split:
- clip-path: polygon(0 0, 100% 0, 100% 88%, 0 100%) scaled fluidly with % units, but could only draw straight lines.
- clip-path: path('M 0 0 L 400 0 Q 200 300 0 240 Z') supported smooth Bezier curves, but was locked to hardcoded pixel numbers—refusing to stretch across responsive containers!
To bridge both worlds cleanly across 100% of browsers today, combine an objectBoundingBox <clipPath clipPathUnits="objectBoundingBox"> where coordinates run normalized from 0.0 to 1.0 (equivalent to 0% to 100% of any element's width and height!):
<!-- Normalized 0..1 curved clip-path that scales fluidly to ANY div size! -->
<svg width="0" height="0" class="sr-only" aria-hidden="true">
<defs>
<clipPath id="fluid-wave-clip" clipPathUnits="objectBoundingBox">
<path d="M 0,0 L 1,0 L 1,0.85 Q 0.75,1 0.5,0.88 T 0,0.90 Z" />
</clipPath>
</defs>
</svg>
<section style="clip-path: url(#fluid-wave-clip);" class="bg-blue-600 text-white py-20 px-6">
<h2>Curved Responsive Clipping Without Fixed Pixels</h2>
</section>
5. Smooth Hover Morphing Rules for clip-path: polygon()
Want an editorial thumbnail or callout card to morph from a subtle chamfered corner into a full rectangle on :hover? Browser interpolation engines enforce two strict rules—violating either causes the shape to snap instantaneously instead of animating smoothly:
- Identical Vertex Count: If your resting
polygon()has 6 coordinate pairs, your:hoverpolygon()must also have 6 coordinate pairs! To collapse a beveled corner into a square corner, move the two bevel vertices onto the exact same(100% 0%)corner coordinate rather than deleting a vertex:
.morph-bevel-card {
/* 5 vertices: top-right corner has a 24px chamfer */
clip-path: polygon(
0% 0%,
calc(100% - 24px) 0%,
100% 24px,
100% 100%,
0% 100%
);
transition: clip-path 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.morph-bevel-card:hover {
/* Still 5 vertices! Vertices 2 & 3 converge smoothly at (100%, 0%) */
clip-path: polygon(
0% 0%,
calc(100% - 0px) 0%,
100% 0px,
100% 100%,
0% 100%
);
}
- Consistent Shape Function: You cannot transition directly from
clip-path: circle(...)toclip-path: polygon(...)—both states must usepolygon()(or bothinset(), or bothcircle()).
6. Alpha Fade Transitions with mask-image
When layering horizontal scrolling code tabs or tag strips, abrupt rectangular clipping on the right edge hides the affordance that more items exist off-screen. A single horizontal mask-image fades overflowing pills smoothly over any background color (unlike a hardcoded white linear-gradient overlay div, which breaks whenever card background color changes!):
.horizontal-scroll-fade {
overflow-x: auto;
mask-image: linear-gradient(
to right,
#000 0%,
#000 calc(100% - 40px),
transparent 100%
);
}
Prototype polygon masks and organic curves directly in our CSS Clip-Path & SVG Blob Maker.