Image hspaceProperty

Image 对象参考手册Image Object

Definition and Usage

The hspace property sets or returns the value of the hspace attribute of an image.

The hspace attribute specifies the whitespace to the left and right edges of an image.

Syntax

imageObject.hspace=pixels


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hspace attribute.


Example

Example

The following example sets the hspace and vspace attributes of an image:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function setSpace(){
    document.getElementById("compman").hspace="50";
    document.getElementById("compman").vspace="50";
}
</script>
</head>
<body>

<img id="compman" src="compman.gif.html" alt="Computerman" width="107" height="98">
<p>Some text. Some text. Some text. Some text.</p>
<input type="button" onclick="setSpace()" value="Set horizontal and vertical spacing">

</body>
</html>

Try it Yourself »


Image 对象参考手册Image Object Other Extensions