Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML DOM Image height Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The HTML DOM Image height Property is used to set or returns the value of the height attribute of the Image element. The height attribute is used to specify the height of the image in terms of pixels. 

Syntax:

It returns the image height Property.

imageObject.height

It sets the image height property.

imageObject.height = pixels

 

Property Values:

  • pixels: It specifies the height of the Image Element in terms of pixels

Return Value: It returns a string value that represents the height of the image in terms of pixels.

Example 1: This example illustrates how to return the image height property. 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
          
        <h2>HTML DOM Image Height Property</h2>
          
        <img id="GFG" src=
            width="400" height="150" />
        <br>
  
        <button onclick="Geeks()">
            Click me!
        </button>
          
        <p id="sudo"></p>
  
    </center>
  
    <script>
        function Geeks() {
            var g = document.getElementById("GFG").height;
              
            document.getElementById("sudo")
                    .innerHTML = g + "px";
        }
    </script>
</body>
  
</html>

Output:

Example 2: Below code sets the image height property.

HTML




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
          
        <h2>HTML DOM Image Height Property</h2>
          
        <img id="GFG" src=
            width="400" height="150" />
        <br>
  
        <button onclick="Geeks()">
            Click me!
        </button>
          
        <p id="sudo"></p>
  
    </center>
  
    <script>
        function Geeks() {
            var g = document.getElementById(
                    "GFG").height = "75";
  
            document.getElementById("sudo")
                    .innerHTML = g + "px";
        }
    </script>
</body>
  
</html>

Output:

Supported Browsers:

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

My Personal Notes arrow_drop_up
Last Updated : 05 Oct, 2021
Like Article
Save Article
Similar Reads
Related Tutorials