Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

HTML | DOM image naturalWidth property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

Syntax : 


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



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

Before click: 

After click: 

 Supported Browsers are listed below:

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


My Personal Notes arrow_drop_up
Last Updated : 21 Jun, 2022
Like Article
Save Article
Similar Reads
Related Tutorials