Image naturalHeight property
Definition and usage
naturalHeight
The property returns the original height of the image.
For example, if you have an image that is originally 200 pixels tall. Then, you use CSS/or use the HTML "height" attribute to set the image style, making its height 500 pixels. The naturalHeight property will return "200", and the height property will return 500.
Tip:Please use naturalWidth property Returns the original width of the image, or uses width property Sets or returns the width property value.
Note:This property is read-only.
Instance
Example 1
Returns the original height of the image:
var x = document.getElementById("myImg").naturalHeight;
Example 2
The difference between the naturalHeight property and the height property:
var x = document.getElementById("myImg").naturalHeight; var y = document.getElementById("myImg").height;
Syntax
imageObject.naturalHeight
Technical Details
Return Value: | A number representing the original height of the image (in pixels). |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |