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

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
How get_template_part helps write reusable code in WordPress?WordPressHow to Recognize an Array in JavaScript?JavaScriptLearn how to give a temporary name to a column or to a table using SQL AliasesSQL/MySQLLearn to Implement Estimated Reading Time using PHP Part 1: The BasicsPHPHow to disable scrolling on html body on menu click using JavaScript?JavaScriptWhat is Git?MiscellaneousHow to Create a Copy of a Table in SQL and MySQL?SQL/MySQLCONCAT and CONCAT_WS Functions in PostgresPostgresOrder By and Group By in PostgresPostgresHow to get start index and end index (as int) of substring in Swift?SwiftStyling Lists with CSSCSSShould we ever delete data from a database?Miscellaneous