Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Object hspace Property

  • Last Updated : 21 Oct, 2021

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

Syntax

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

  • 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.

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() {
  
            // Accessing Object element
            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() {
  
            // Accessing Object element.
            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



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!