HTMLImageElement
The interface for <img>. Extends HTMLElement → Element.
Reflected properties
All setters are guarded and throw NoModificationAllowedError on a read-only document.
| Property | Attribute | Type | Notes |
|---|---|---|---|
src |
src |
string | Reflects verbatim — no base-URL resolution. |
alt |
alt |
string | Reflects the content attribute verbatim. |
width |
width |
number | unset → 0. |
height |
height |
number | unset → 0. |
srcset |
srcset |
string | Reflects the content attribute verbatim. |
sizes |
sizes |
string | Reflects the content attribute verbatim. |
loading |
loading |
enum | Keywords: lazy · eager. Missing → "eager"; invalid → "eager". |
decoding |
decoding |
enum | Keywords: sync · async · auto. Missing → "auto"; invalid → "auto". |
crossOrigin |
crossorigin |
nullable enum | Keywords: anonymous · use-credentials. Missing attribute → null; any other present value → "anonymous"; assigning null removes the attribute. |
referrerPolicy |
referrerpolicy |
enum | Keywords: "" · no-referrer · no-referrer-when-downgrade · same-origin · origin · strict-origin · origin-when-cross-origin · strict-origin-when-cross-origin · unsafe-url. Missing → ""; invalid → "". |
See also
- Element —
getAttribute/setAttribute, content,classList, traversal, insertion - HTMLElement — the global reflected properties every HTML element inherits
- JavaScript DOM API — the interface hierarchy and
instanceof