Lesson 32 of 50
cssCSS Clip‑Path & Masking
7 mins
Course progress64%
What you'll learn
Keep this idea in mind as you work through the lesson.
Lesson 32 of 50
css7 mins
Keep this idea in mind as you work through the lesson.
clip-path and mask-image let you cut or mask elements into arbitrary shapes.
clip-pathcircle(), ellipse(), polygon()) and SVG path syntax (path('…'))..card {
width:300px; height:200px; background:#0066cc;
clip-path:polygon(0 0, 100% 0, 85% 100%, 0 85%);
}
mask-imagemask-size, mask-position, and mask-repeat..avatar {
width:200px; height:200px; background:url('portrait.jpg') center/cover;
mask-image:radial-gradient(circle at center, transparent 0%, black 70%);
mask-size:cover;
}
clip-path@keyframes morph {
0% { clip-path:circle(0% at 50% 50%); }
100% { clip-path:circle(50% at 50% 50%); }
}
.box { animation:morph 1s forwards ease-out; }
The element reveals itself gradually, useful for onboarding screens.
clip-path – supported in all modern browsers; IE needs the older -ms- prefix.mask-image – supported in Chrome, Safari, Edge; Firefox requires the -moz- prefix (and still experimental).polygon() list, embed an SVG <clipPath> definition and reference it with clip-path:url(#myClip).Both properties only affect visual rendering; screen readers still encounter the full element. Use aria-hidden="true" on decorative graphics if they add noise.