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 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Is there a difference between SCSS and Sass?SCSSHow to add Read More Read Less Button using JavaScript?JavaScriptAn Example of Cross-site Scripting (XSS) Attack in PHP and How to Avoid It?PHPHow to add a Line Chart in Angular App?AngularWordPress: How to loop through a repeater field in ACF?WordPressHow to Check If a Variable is an Integer, a Float, a Number, NaN, an Infinite or a Numeric in PHP?PHP:in-range and :out-of-range selector in CSSCSSHow to Draw a Circle in HTML5 Using Canvas Tag?HTMLHow to zoom an image inside a box on hover?CSSColleague UI Basics: The Context AreaColleagueJSON.stringify() in JavaScriptJavaScriptUse SwiperJS to create mobile touch sliders fastMiscellaneous