ⓘ img – image # T
The
img
element represents an image.
Additional constraints and admonitions #
-
An “img” element must have an
“alt” attribute, except under certain
conditions. For details, consult guidance on
providing text alternatives for images.
http://www.w3.org/wiki/HTML/Usage/TextAlternatives
-
The element “img”
with the attribute “usemap” must not
appear as a descendant of the “a” element.
-
The element “img”
with the attribute “usemap” must not
appear as a descendant of the “button” element.
-
The “img” element with the
“ismap” attribute set must have an ancestor
“a” element with the “href” attribute.
-
The “longdesc” attribute on the “img” element is obsolete.
Use a regular “a” element to link to the description.
-
The “name” attribute on the “img” element is obsolete.
Use the “id” attribute instead.
-
The “align” attribute on the “img” element is obsolete.
Use CSS instead. http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes
-
The “hspace” attribute on the “img” element is obsolete.
Use CSS instead. http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes
-
The “vspace” attribute on the “img” element is obsolete.
Use CSS instead. http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes
-
The “border” attribute on the “img” element is obsolete.
Use CSS instead. http://wiki.whatwg.org/wiki/Presentational_elements_and_attributes
-
The “border” attribute on the “img” element is obsolete.
Consider specifying “img { border: 0; }“ in CSS instead.
Permitted parent elements #
any element that can contain
phrasing elements
DOM interface #
[NamedConstructor=Image(),
NamedConstructor=Image(unsigned long width),
NamedConstructor=Image(unsigned long width, unsigned long height)]
interface HTMLImageElement : HTMLElement {
attribute DOMString alt;
attribute DOMString src;
attribute DOMString crossOrigin;
attribute DOMString useMap;
attribute boolean isMap;
attribute unsigned long width;
attribute unsigned long height;
readonly attribute unsigned long naturalWidth;
readonly attribute unsigned long naturalHeight;
readonly attribute boolean complete;
};