Open In App

How to create shape using CSS clipping ?

Last Updated : 22 Jul, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

You can easily create shapes using the clip-path property in CSS. Actually clip-path property lets you clip an element to a basic shape. The basic shape like circle, ellipse, the polygon can be achieved using the <basic-shape> property value of clip-path which will be discussed further in this article.

Property Value:

  • <basic-shape>: It includes some shapes like circles, rectangles, ellipse, etc that clips the given image.

Syntax:

clip-path: <basic-shape> 

Note: clip-path allows to clip the visible portion of SVG elements, images, or any HTML element.

Example 1: The following example creates shapes like circles, polygons.

  • Polygon:

Syntax:

clip-path: polygon(pairs of X and Y coordinates)
  • Circle:

Syntax:

clip-path: circle(radius);

Output:

circle and polygon

Example 2: The following example creates Ellipse and inset shape.

  • Ellipse:

Syntax:

 clip-path: ellipse(radiusX radiusY at posX posY)

Output:

ellipse and inset

Example 3:  The following example creates circle and heptagon shapes

Syntax for Circle:

clip-path: circle(radius, shifted center by X, shifted center by Y)

Output:

Example 4: The following example creates ellipse and inset shapes.

Syntax for ellipse:

clip-path: ellipse(x, y) 

Syntax for inset:

clipt-path: inset(top, right, bottom, left)

Output:

ellipse and inset

Similar Reads