ImageElement
The HTMLImageElement interface provides special properties and methods for manipulating the layout and presentation of img elements.
Documentation HTMLImageElement by Mozilla Contributors, licensed under CC-BY-SA 2.5.
Instance Members
alt: StringIs a DOMString that reflects the alt HTML attribute, thus indicating fallback context for the image.
src: StringIs a DOMString that reflects the src HTML attribute, containing the full URL of the image including base URI.
srcset: StringIs a DOMString reflecting the srcset HTML attribute, containing a list of candidate images, separated by a comma (',', U+002C COMMA). A candidate image is a URL followed by a 'w' with the width of the images, or an 'x' followed by the pixel density.
crossOrigin: StringIs a DOMString representing the CORS setting for this image element. See CORS settings attributes for further details.
useMap: StringIs a DOMString that reflects the usemap HTML attribute, containing a partial URL of a map element.
referrerPolicy: StringIs a DOMString that reflects the referrerpolicy HTML attribute indicating which referrer to use in order to fetch the image.
isMap: BoolIs a Boolean that reflects the ismap HTML attribute, indicating that the image is part of a server-side image map.
width: IntIs a unsigned long that reflects the width HTML attribute, indicating the rendered width of the image in CSS pixels.
height: IntIs a unsigned long that reflects the height HTML attribute, indicating the rendered height of the image in CSS pixels.
decoding: StringReturns a DOMString representing a hint given to the browser on how it should decode the image.
naturalWidth: IntReturns a unsigned long representing the intrinsic width of the image in CSS pixels, if it is available; otherwise, it will show 0.
naturalHeight: IntReturns a unsigned long representing the intrinsic height of the image in CSS pixels, if it is available; else, it shows 0.
complete: BoolReturns a Boolean that is true if the browser has finished fetching the image, whether successful or not. It also shows true, if the image has no HTMLImageElement.src value.
name: StringIs a DOMString representing the name of the element.
align: StringIs a DOMString indicating the alignment of the image with respect to the surrounding context. The possible values are "left", "right", "justify", and "center".
hspace: IntIs a long representing the space on either side of the image.
vspace: IntIs a long representing the space above and below the image.
longDesc: StringIs a DOMString representing the URI of a long description of the image.
border: StringIs a DOMString that is responsible for the width of the border surrounding the image. This is now deprecated and the CSS border property should be used instead.
sizes: StringIs a DOMString reflecting the sizes HTML attribute.
currentSrc: StringReturns a DOMString representing the URL to the currently displayed image (which may change, for example in response to media queries).
lowsrc: StringIs a DOMString that refers to a low-quality (but faster to load) copy of the image.
x: IntReturns a long representing the horizontal offset from the nearest layer. This property mimics an old Netscape 4 behavior.
y: IntReturns a long representing the vertical offset from the nearest layer. This property is also similar to behavior of an old Netscape 4.