Clip-path defines the region of an element that remains visible. Content outside the region is clipped from painting; the property's shape does not rewrite the element's ordinary layout dimensions.
CSS clip-path: clip decoration without hiding required content
When to use it
A case header has a diagonal decorative accent. Put that accent in its own element and clip it, rather than clipping the entire header and losing the title, status, or focus outline. A polygon can express the edge without a separate image request. The sample uses a color block behind the real content. Check narrow widths, longer translated titles, and high zoom, where an accent that occupies too much of the header can obscure text even if the text itself is not clipped. A clipping shape is presentation only; the DOM must still contain the actual information. If an action sits near the shaped edge, verify its full pointer target and focus indicator remain visible.
.case-header { position: relative; isolation: isolate; }
.case-header__accent { position: absolute; inset: 0; z-index: -1; background: #dceaf0; clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%); pointer-events: none; }Cost and verification
A simple polygon may be cheap, but animating a complex clipping path across many large surfaces can add paint work. Measure on target devices before making it a motion effect. The shape changes visible pixels and pointer hit regions, not the space reserved in layout, so neighboring boxes may still follow the rectangular dimensions. Keep enough contrast when the decorative region fails to render. Do not use clipping for redaction: underlying data and assets remain available. Review print and forced-color output, where decorative regions may disappear or change.
Common Mistakes
- Do not clip the element containing the only visible title or action.
- Do not treat clipping as data redaction.
- Do not assume a shaped surface occupies shaped layout space.
Connected lessons
- CSS Property Decisions
- CSS backgrounds: reserve background images for decoration
- CSS isolation: give a component a stacking boundary
- CSS pointer-events: remove decorative hit targets carefully
