Yogesh Chauhan's Blog

clip and clip-path properties in CSS

in CSS on March 27, 2021

clip CSS property (deprecated)

We can use clip property to show only a portion of any element for e.g. an image.

We can apply clip property only to elements with position property set to fixed or absolute.

We can clip the element in the shape of a rectangle using rect(top corner, right corner, bottom corner, left corner).

We can not clip element if the overflow property has been set as visible as its like telling browsers to do two completely opposite things.

The clip property still works but it won’t work forever. Try to use clip-path property instead.

clip-path CSS property

clip-path property is a newer and better version of clip.

With the clip-path property we can clip/show different shaped regions, not just a rectangle.

The biggest advantage of clip-path property is that it works really well with svg elements which just boost our imagination.

clip-path CSS property Examples

clip-path-circle-50

clip-path: circle(40%)

clip-path:ellipse

clip-path:polygon

Checkout some really good SVG clip-path examples on MDN.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
3 ways to pass a variable in url() function in SCSS (Sass)SCSSHow to Find the Highest (or Lowest) Number in an Array in JavaScript?JavaScriptHow does @extend rule work in SCSS (Sass)?SCSSWhat are Controlled Components in React?ReactHow to create a simple tab interaction using CSS?CSSHow to Use ROLLUP Operator in SQL and MySQL?SQL/MySQLHow to add Google Static Map using ACF map field?WordPressThe difference between isFinite() method and isFinite() function in JavaScriptJavaScriptIs there a CSS parent selector?CSStransform-origin Property in CSSCSSHow to add a ribbon on top of a container using CSS?CSSHow to implement NSNumberFormatter in Swift for currency?Swift