Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

clip-path — clipping the visible region

The clip-path property restricts the visible region of an element and its descendants to a chosen shape without changing the space occupied in layout.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

clip-path: <clip-source> | [ <basic-shape> || <geometry-box> ] | none;
<clip-source> = <url>
<geometry-box> = <shape-box> | fill-box | stroke-box | view-box

clip-path clips painting of an element and its descendants without changing layout geometry. Regions outside the path do not receive pointer events. Its initial value is none; the property is not inherited.

The value can be a shape, a reference box alone, or url("#clip") referencing an SVG clipPath element. A shape defaults to border-box as its reference box. An invalid reference causes no clipping.

In the example, polygon() connects three vertices. Each pair specifies x and y coordinates: percentages refer to the reference box's width and height respectively. The resulting triangle has vertices at (80px, 0px), (160px, 120px), and (0px, 120px), relative to the element's top-left corner. The layout box remains 160px × 120px.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>clip-path</title>
<style>
  .triangle {
    width: 160px;
    height: 120px;
    background: #0066cc;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
  }
</style>
<div class="triangle"></div>
</html>

Result

A blue triangle with vertices at (80px, 0px), (160px, 120px), and (0px, 120px), relative to the element's top-left corner. Its layout box remains 160px × 120px.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources