HTML | DOM Style clip Property
Last Updated :
08 Aug, 2022
The Style clip property in HTML DOM is used to set or return the visible part of a positioned element.
Syntax:
- It returns the clip property.
object.style.clip
- It is used to set the clip property.
object.style.clip = "rect(top right bottom left)|normal|initial|
inherit"
Note: This property has been deprecated.
Return Values: It returns a string value, which represents the part of a positioned element that is visible.
Property Values:
1. rect(top right bottom left): This value is used to clip the element in a rectangular shape. The top, right, bottom and left values are used to define the points of the rectangle.
Example-1:
html
<!DOCTYPE html>
<html>
<head>
<title>
DOM Style clip Property
</title>
<style>
#myImage {
position: absolute;
}
button {
margin-top: 400px;
}
</style>
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<b>DOM Style clip Property</b>
<p>
The clip property is used to specify
the part of a positioned element that is visible.
</p>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190311222622/sample-image.png"
id="myImage">
<button onclick="setClip()">
Set Clip Property
</button>
<!-- Script to set clip to rect() -->
<script>
function setClip() {
elem =
document.querySelector('#myImage');
elem.style.clip =
'rect(75px 250px 250px 75px)';
}
</script>
</body>
</html>
Output:
Before clicking the button:
After clicking the button:

2. normal: This value does not clip the element. This is the default value.
Example-2:
html
<!DOCTYPE html>
<html>
<head>
<title>
DOM Style clip Property
</title>
<style>
#myImage {
position: absolute;
clip: rect(50px 200px 200px 50px);
}
button {
margin-top: 400px;
}
</style>
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<b>DOM Style clip Property</b>
<p>
The clip property is used to specify
the part of a positioned element
that is visible.
</p>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190311222622/sample-image.png"
id="myImage">
<button onclick="setClip()">
Set Clip Property
</button>
<!-- Script to set clip to auto -->
<script>
function setClip() {
elem =
document.querySelector('#myImage');
elem.style.clip = 'auto';
}
</script>
</body>
</html>
Output:
Before clicking the button:
After clicking the button:

3. initial: This is used to set this property to its default value.
Example-3:
html
<!DOCTYPE html>
<html>
<head>
<title>
DOM Style clip Property
</title>
<style>
#myImage {
position: absolute;
clip: rect(75px 300px 300px 75px);
}
button {
margin-top: 400px;
}
</style>
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<b>
DOM Style clip Property
</b>
<p>
The clip property is used to specify
the part of a positioned element
that is visible.
</p>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190311222622/sample-image.png"
id="myImage">
<button onclick="setClip()">
Set Clip Property
</button>
<!-- Script to set clip to initial -->
<script>
function setClip() {
elem =
document.querySelector(
'#myImage');
elem.style.clip = 'initial';
}
</script>
</body>
</html>
Output:
Before clicking the button:
After clicking the button:

4. inherit: This inherits the property from its parent.
Example-4:
html
<!DOCTYPE html>
<html>
<head>
<title>
DOM Style clip Property
</title>
<style>
#parent {
clip: rect(75px 300px 300px 75px);
}
#myImage {
position: absolute;
}
button {
margin-top: 400px;
}
</style>
</head>
<body>
<h1 style="color: green">
GeeksforGeeks
</h1>
<b>DOM Style clip Property</b>
<p>
The clip property is used to specify
the part of a positioned element that
is visible.
</p>
<div id="parent">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190311222622/sample-image.png"
id="myImage">
</div>
<button onclick="setClip()">
Set Clip Property
</button>
<!-- Script to set clip to inherit -->
<script>
function setClip() {
elem =
document.querySelector(
'#myImage');
elem.style.clip = 'inherit';
}
</script>
</body>
</html>
Output:
Before clicking the button:
After clicking the button:

Supported Browsers: The browser supported by DOM Style clip property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Apple Safari
Similar Reads
HTML DOM Style backgroundClip Property The DOM style backgroundClip Property is used to set or return the painting area of the background. Syntax: It is used to return the backgroundClip property.object.style.backgroundClip It is used to set the backgroundClip property. object.style.backgroundClip = "border-box|padding-box|content-box|in
1 min read
HTML DOM Style top Property The HTML DOM Style top Property is used to set or return the top position of a positioned element including padding, scrollbar, border, and margin. Syntax: It returns the top property.object.style.topIt sets the top property.object.style.top = "auto | length | % | initial | inherit"Property Values:
2 min read
HTML DOM Style border Property The HTML DOM Style border Property is used to set or return the style of an element's border. We can set the different styles of the border for individual sides (top, right, bottom, left). The border-style property can take multiple values for each side. SyntaxIt is used to return the Style Propert
2 min read
HTML DOM Style borderTop Property The DOM style borderTop property is used to set or return the three different border-top property such as border-top-width, border-top-style, and border-top-color of an element. Syntax: It returns the borderTop property. object.style.borderTopIt is used to set the borderTop property. object.style.bo
2 min read
HTML | DOM Style background Property The Style background property in HTML DOM is a short hand property used to set or return the background of an element. It can help to manipulate one or more of eight background properties. Syntax: It returns the background property.object.style.backgroundIt is used to set the background property.obj
7 min read
HTML DOM Style borderLeft Property HTML DOM Style borderLeft property allows manipulation of the left border style of an element via JavaScript. It controls the border's width, style, and color, affecting the element's visual presentation and layout. HTML DOM Style borderLeft Property Syntax:Get the borderLeft Property.object.style.b
2 min read