Open In App

HTML DOM Object hspace Property

Improve
Improve
Like Article
Like
Save
Share
Report

The HTML DOM Object hspace property is used to set or return the value of the hspace attribute of the <object> element. The hspace attribute is used to specify the number of whitespaces for the left and right side of an Object.

Syntax

It returns the hspace Property.

objObject.hspace;

It sets the hspace Property.

objObject.hspace="pixels";

Property Value: It contains the numeric value that specify the number of white spaces from the left and right side of an Object.

Return Value : It returns a numeric value which represent the horizontal spaces around an element. 

Note: The  hspace attribute is not supported by HTML5.

Example 1: Below example returns the object hspace property.

HTML




<!DOCTYPE html>
<html>
<body>
    <center>
        <h2>GeeksForGeeks</h2>
        <h2>DOM Object hspace Property</h2>
         
<p>
            <object id="myobject" width="180"
                height="78" hspace="50" data=
            </object>
            A Good Platform for earning and learning.
        </p>
 
        <br>
        <button onclick="Geeks()">
            Click it
        </button>
        <p id="gfg" style="color:green;font-size:25px;"></p>
 
    </center>
    <script>
        function Geeks() {
 
            // return Object hspace Property
            var x = vdocument.getElementById("myobject").hspace;
 
            document.getElementById("gfg").innerHTML = x;
        }
    </script>
</body>
</html>


Output:

Example 2: Below example sets the Object hspace property.

HTML




<!DOCTYPE html>
<html>
<body>
    <center>
        <h2>GeeksForGeeks</h2>
        <h2>DOM Object hspace Property</h2>
         
<p>
            <object id="myobject" width="180"
                height="78" hspace="50"
                data=
            </object>
            A Good Platform for earning and learning.
        </p>
 
        <br>
        <button onclick="Geeks()">
            Click it
        </button>
        <p id="gfg" style="color:green;font-size:25px;"></p>
 
    </center>
    <script>
        function Geeks() {
 
            // set Object hspace Property
            var x = document.getElementById(
                    "myobject").hspace = "15";
 
            document.getElementById("gfg").innerHTML = x;
        }
    </script>
</body>
</html>


Output:

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Opera
  • Firefox
  • Apple Safari


Last Updated : 25 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads