YouTip LogoYouTip

Prop Style Clip

HTML DOM Style clip Property | Novice Tutorial var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a5d1212d3e0b459fcb3a01e05a1a6ae3"; var s = document.getElementsByTagName("script"); s.parentNode.insertBefore(hm, s); })();

HTML DOM Style clip Property

Instance

Return the clipping region of an image:

document.getElementById("myImg").style.clip

Try it Β»


Definition and Usage

The clip property sets or returns the visible part of a positioned element.

Note: If "position:static", the clip property will not work.

Note: The clip property is deprecated. Please use the clip-path property as an alternative.


Browser Support

Internet ExplorerFirefoxOperaChromeSafari

The numbers in the table specify the first browser version that fully supports the property.

Property Chrome IE Firefox Safari Opera
clip 1.0 8.0 1.0 1.0 7.0

Syntax

Return the clip property:

object.style.clip

Set the clip property:

object.style.clip="rect(top, right, bottom, left)|auto|initial|inherit"

Property Values

Value Description
rect(top, right, bottom, left) Clips an absolutely positioned element. The value comes from offsetting from the element's top-left corner.

The four parameters:
top: top offset
right: right offset
bottom: bottom offset
left: left offset
auto Default value. No clipping.
initial Sets this property to its default value. Please read about initial.
inherit Inherits this property from its parent element. Please read about inherit.

Technical Details

Default Value: auto
Return Value: A String, representing the clipping region of a positioned element
CSS Version CSS2

More Examples

Example

Set the clipping region of an image:

document.getElementById("myImg").style.clip = "rect(0px 50px 200px 0px)";

Try it Β»

Example

Change the clipping region of an image:

document.getElementById("myImg").style.clip = "rect(100px 250px 300px 100px)";

Try it Β»

Example

Return the current clipping region using alert:

alert(document.getElementById("myImg").style.clip);

Try it Β»


Related Pages

CSS Tutorial: CSS clip

CSS Reference: clip property

HTML DOM Reference: Style object

← Prop Style CssfloatProp Style Clear β†’