DOM Properties

HTMLImageElement.naturalWidth

Read-only. Reports the density-corrected intrinsic image width in CSS pixels, or zero when intrinsic data is unavailable. It differs from the rendered width and from an author-supplied width attribute. Example result: 0.

Formal Syntax & Structure

html syntaxhtml
element.naturalWidth

Return Value

number

Property value. Read-only.

Working Example

Example Snippethtml
<img id="demo" alt="No resource" width="200"><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  result(e.naturalWidth);</script>
HTML Reference