Image hspaceProperty
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
![]()
![]()
![]()
![]()
![]()
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>
<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 Object Other Extensions