Style clip attribute

Definition and usage

clip Set or return which part of the positioning element is visible.

See also:

CSS Tutorial:CSS Positioning

CSS Reference Manual:clip attribute

Instance

Example 1

Clip the image into the specified shape:

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

Try it yourself

Example 2

Return the clip attribute:

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

Try it yourself

Syntax

Return the clip attribute:

object.style.clip

Set the clip attribute:

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

Attribute value

Value Description
auto Default. Does not clip the element.
rect(top right bottom left) Shapes are clipped by four coordinates.
initial Set this attribute to its default value. See also initial.
inherit This attribute inherits from its parent element. See also inherit.

Technical details

Default value: None
Return Value: A string representing the visible part of the positioned element.
CSS Version: CSS2

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support