HTML DOM clip Property
Complete Style Object Reference
Definition and Usage
The clip property sets the shape of an element.
What happens if an image is larger than the element it goes inside? - The
"clip" property lets you specify the dimensions of an element that should be
visible, and the element is clipped into this shape, and displayed.
Syntax
Object.style.clip=rect(top,right,bottom,left)|auto
|
Possible Values
| Value |
Description |
| rect(top,right,bottom,left) |
Sets the shape of the element |
| auto |
The browser sets the shape of the element |
Tips and Notes
Note: This property cannot be used for elements with an "overflow"
property set to "visible".
Example
The following example clips an image into a specified shape:
<html>
<head>
<style type="text/css">
img
{
position:absolute;
top:100px;
}
</style>
<script type="text/javascript">
function clipImage()
{
document.getElementById("img1").style.clip="rect(0px,50px,50px,0px)";
}
</script>
</head>
<body>
<img id="img1" border="0" src="logocss.gif" width="95" height="84" />
<input type="button" onclick=clipImage() value="Clip image" />
</body>
</html>
|
Try-It-Yourself Demos
Clip -
Clip an image into a specified shape
Complete Style Object Reference
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
|
|