CSS Clip-Path Generator

Create stunning shapes and masks visually

Settings
Comma separated x% y% pairs
Live Preview
clip-path: circle(40% at 50% 50%);

The Ultimate Guide to CSS Clip-Path: Sculpting the Web

Introduction: Breaking the Box Model

Since the dawn of the web, web design was tyrannized by the box model. Everything has been a rectangle. Images are rectangles. Divs are rectangles. Even "rounded" buttons are just rectangles with shaved corners, masquerading as curves. Any attempt to break this mold required heavy PNGs with transparency or complex hacks.

CSS Clip-Path changes the game. It allows you to "clip" an element into visible and hidden regions, effectively letting you draw any shape you want—circles, triangles, hexagons, or complex polygons—natively in the browser. Unlike `border-radius`, which only affects corners, `clip-path` creates a totally new bounding area. The content outside the clip path simply vanishes, but the element itself retains its original flow dimensions, creating fascinating layout possibilities.

The Four Basic Shapes

Our generator focuses on the four foundational shapes supported by basic CSS, which cover 90% of use cases:

  • Circle(): The classic circle. Perfect for user avatars (`circle(50%)`) or circular reveal animations. You define a radius and a center point. It is mathematically perfect and resolution-independent.
  • Ellipse(): A stretched circle. You define an x-radius (width), a y-radius (height), and a center point. Great for thought bubbles or futuristic UI elements where a perfect circle feels too rigid.
  • Inset(): A rectangle within a rectangle. Why use this instead of `width/height`? Because `inset()` allows you to crop an image non-destructively without changing the layout flow of the page. You can define offsets from Top, Right, Bottom, and Left, acting like a digital cropping tool.
  • Polygon(): The most powerful function. You can define as many X/Y points as you want. 3 points make a triangle. 5 make a star. 6 make a hexagon. The possibilities are infinite, and this tool lets you visualize those coordinates instantly.

Advanced Techniques: Animations & Images

Morphing Shapes (The "Shape-Shifter" Effect)

One of the coolest features of `clip-path` is that it is animatable. As long as the number of points in a polygon remains the same, the browser can interpolate the values. For example, you can morph a hamburger menu icon (3 bars) into an 'X' close icon purely with CSS transitions. Or transform a square into a triangle on hover.

Creative Image Masking

Designers often want images to break grid layouts or have jagged edges. Instead of editing the standard JPG in Photoshop (which destroys the original data and makes responsive sizing hard), you can apply a `clip-path` in CSS. This keeps the file editable. If you change the photo, the shape remains. It is also lighter than using a mask image because it is vector-based.

Performance and Accessibility

Performance: `clip-path` is highly performant. Browsers typically handle clipping on the GPU (Graphics Processing Unit), meaning animations are buttery smooth (60fps) and don't trigger expensive Layout re-calculations on the CPU, unlike changing `width` or `height`.

Accessibility: Be careful! Clipping hides visual content, but screen readers might still read the hidden text depending on the browser. It doesn't use `display: none`. Always ensure your visible shape contains all the necessary context, or use `aria-hidden` if the clipped content is irrelevant.

Beyond Basic Shapes: SVG Paths

While this tool covers basic functions, CSS also supports referencing an external SVG definition via `clip-path: url(#myClip)`. This allows for curves (Beziers) that `polygon` cannot handle. Furthermore, the newer `path()` syntax allows writing SVG path data directly in CSS (`path('M10 10 H 90 V 90 H 10 Z')`), unlocking complex logo reveals and organic blob animations.

Interaction with Box Model

It is important to note that `clip-path` clips the rendered pixels but does not change the layout box. If you clip a 500x500 div into a 10x10 circle, the text around it will still wrap as if the 500x500 div is there. To make text wrap around the shape, you need a different property called CSS Shapes (`shape-outside`), which often pairs beautifully with `clip-path`.

Browser Support and Fallbacks

Support is excellent across all modern browsers (Chrome, Edge, Firefox, Safari). However, older versions of Safari required the `-webkit-` prefix. Our tool generates the standard syntax, which should work for 99% of global users. For extremely old browsers (IE11), the property is simply ignored, meaning users will see the full unclipped box—a graceful degradation.

Frequently Asked Questions (FAQ)

Does clip-path support shadows?

This is tricky. Standard `box-shadow` is clipped off because it exists outside the element's border box and is counted as "outside" the clip area. To add a shadow to a clipped element, you need to use `filter: drop-shadow()` instead. It essentially "traces" the clipped shape and applies a shadow to it, which looks fantastic on complex polygons.

Does it work in all browsers?

Yes. `clip-path` is supported in all modern browsers (Chrome, Edge, Firefox, Safari) since roughly 2014. Internet Explorer (IE) does NOT support it. Since IE is officially deprecated by Microsoft, it is safe to use in almost all production environments today.

Can I click on the hidden areas?

No, and that's a key feature! The "clipped" area is removed from the pointer-events. If you have a link behind a clipped region, and you click on the transparent/clipped part of the top element, the click will pass through to the link behind it. This allows for complex, layered interactive UIs.

How do I center my specific shape?

For `circle` and `ellipse`, use the `at` keyword (e.g., `at 50% 50%`). For `polygon`, you have to calculate the coordinates manually relative to the box size (0% to 100%). Using our generator is the easiest way to visualize this centering!

Is clip-path the same as mask-image?

They are similar tools for hiding content, but different engines. `clip-path` is vector-based, creating hard, crisp edges. `mask-image` is pixel-based (raster), allowing for alpha transparency, gradients, and soft edges. Clipping is generally more performant because the browser only calculates the path vectors.

Can I animate from a Circle to a Square?

Not directly by transitioning from `clip-path: circle()` to `clip-path: inset()`. However, you can cheat! Define a "circle" using a polygon with many points (e.g. 20 points) that roughly form a circle, and animate it to a square (also defined with 20 points). As long as point counts match, CSS will morph them smoothly.

Why is my text cut off?

Clip-path is destructive visually. The browser renders the text, then slices it. If your text flows outside the defined shape bounds, it is invisible. Ensure your container is large enough or use padding to push text inside the "safe zone" of your shape.