Skip to content
Related Articles

Related Articles

HTML | DOM Object Height Property

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 25 Aug, 2022
View Discussion
Improve Article
Save Article

The HTML | DOM Object height Property in HTML DOM is used to set or return the height of the Object. The height attribute is used to specify the height of the Object. 

Syntax: 

  • It returns the height property
objObject.height
  • It is used to set the height property.
objObject.height = pixels

Property Values: It contains the value i.e pixel Which is used to specify the height of the Object in terms of the pixel. 

Return Value: It returns a numeric value which represents the height of the object in terms of the pixel. 

Example-1: This Example returns the height Property. 

HTML




<!DOCTYPE html>
<html>
<body>
    <center>
        <object id="myobject"
                width="400"
                height="200"
                data=
        </object>
        <h2>DOM Object height Property</h2>
        <p>Click the button to get the
          height of the embedded file.</p>
        <button onclick="Geeks()">
            Click it
        </button>
        <p id="gfg"
           style="color:green;
                  font-size:25px;">
          </p>
    </center>
    <script>
        function Geeks() {
 
            // return Object height Property
            var x =
                document.getElementById(
                    "myobject").height;
 
            document.getElementById(
                "gfg").innerHTML = x;
        }
    </script>
</body>
</html>

Output: 

Before Clicking On Button:

  

After Clicking On Button:

  

Example-2: This Example sets the height Property. 

HTML




<!DOCTYPE html>
<html>
<body>
    <center>
        <object id="myobject"
                width="400"
                height="200"
                data=
        </object>
        <h2>DOM Object height Property
          </h2>
        <p>Click the button to change
          the height of the embedded file.</p>
        <button onclick="Geeks()">
            Click it
        </button>
        <p id="gfg"
           style="color:green;
                  font-size:25px;">
          </p>
    </center>
    <script>
        function Geeks() {
 
            // set Object height Property
            var x =
                document.getElementById(
                    "myobject").height = "150";
 
            document.getElementById(
                "gfg").innerHTML = x;
        }
    </script>
</body>
</html>

Output: 

Before Clicking On Button:

  

After Clicking On Button:

  

Supported Browsers:

  • Google Chrome
  • Mozilla Firefox
  • Edge
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!