DOM Properties

HTMLImageElement.naturalHeight

Read-only intrinsic density-corrected height in CSS pixels, or zero when unavailable. It can differ from displayed height when CSS resizes the image. Example result: 8.

Formal Syntax & Structure

html syntaxhtml
image.naturalHeight

Return Value

number

Intrinsic height in CSS pixels.

Working Example

Example Snippethtml
<p>  Result:  <output id="result"></output></p><script>  const result = document.getElementById("result");  (async () => {  const image = new Image(); image.src = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8"><rect width="12" height="8" fill="green"/></svg>');  await image.decode(); result.textContent = image.naturalHeight;  })().catch(error => { result.textContent = "Error: " + error.name; });</script>
HTML Reference