/

HTML / CSS / JavaScript Tutorial

JavaScript img object property: naturalHeight

[this page | pdf | back links]

The naturalHeight property of the JavaScript DOM object corresponding to the HTML <img> element returns the original height of the image underlying the <img> element.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
original image (width x height of 32 x 32): <img src="NematrianLogo.png"><br>
resized image (to width x height of 23 x 40): <img id="element" src="NematrianLogo.png" style="width: 23px; height: 40px"><br><br>
naturalHeight of resized version: <b id="x2"></b>

<script>
var x = document.getElementById("element");
document.getElementById("x2").innerHTML = x.naturalHeight;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile