Clipping and Masking

suggest change

Clipping and masking both limit what is painted, but they use different models:

Clipping

.avatar {
  clip-path: circle(50%);
}

.badge {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

Basic shape functions include inset(), circle(), ellipse(), and polygon(). A url() can reference an SVG clip path.

Masking

.faded-image {
  mask-image: linear-gradient(to bottom, black 70%, transparent);
  mask-repeat: no-repeat;
  mask-size: cover;
}

Mask layers use properties analogous to backgrounds, including mask-position, mask-size, mask-repeat, mask-origin, and mask-clip.

Modern browsers implement the standard unprefixed clipping and masking properties for common cases. If a complex mask is decorative, provide a readable unclipped baseline and test the exact mask mode, image source, and compositing behavior required by the project.

Clipping does not change layout geometry or the element's accessibility tree. Do not clip away focusable controls or essential content.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents