Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM image naturalHeight property

  • Last Updated : 30 Dec, 2020

naturalHeight : This property is used to get the original height of an image. Since the height of an image to be displayed on the webpage can be modified using the ‘height’ attribute in the <img> tag, hence the naturalHeight property becomes useful in situations where the original height of the image is required rather than the customized one and it is a read-only property.

Syntax :

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


Return Value: It returns the original height of an image in pixels.


        <img src=
             id="image" alt="" width="250" height="205" 
             class="alignnone size-medium wp-image-1092360" />
        <button type="button" onclick="getHeight()">Click</button>
        <div id="text"></div>
        function getHeight() {
            var imgObject = document.getElementById("image");
            var output = document.getElementById("text");
            output.innerHTML = "Height of image: " + imgObject.height +
                "<br>naturalHeight of image: " + imgObject.naturalHeight;

Before click:

After click:

    Supported browsers :

  • Google Chrome
  • Internet Explorer 9.0 or above
  • Mozilla Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :