HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Clip an image
What happens if an image is larger than its containing element?
The clip
property
lets you specify a rectangle to clip an absolutely positioned element. The
rectangle is specified as four coordinates, all from the top-left corner of the
element to be clipped.
clip
property does not work if "overflow:visible".
clip
property is deprecated
and will be replaced by the
clip-path
property in the future.
Default value: | auto |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS2 |
JavaScript syntax: | object.style.clip="rect(0px,50px,50px,0px)" Try it |
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
clip | 1.0 | 8.0 | 1.0 | 1.0 | 7.0 |
Value | Description | Demo |
---|---|---|
auto | No clipping will be applied. This is default | Demo ❯ |
shape | Clips an element. The only valid value is: rect (top, right, bottom, left) | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS tutorial: CSS Positioning
HTML DOM reference: clip property