XML technologies / HTML & XHTML / Alphabetical list of HTML and XHTML elements / img
(Excerpt from "HTML & XHTML ─ kurz & gut" by Jennifer Niederst Robbins)
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
img
HTML 4.01 | HTML 5 |
HTML: <img>; XHTML: <img/> or <img />
Places an image on the page. The attributes src and alt are always required. Many attributes controlling the presentation and positioning of the img element are deprecated in favor of stylesheets.
Start/end tag
This is an empty element. HTML forbids an end tag. In XHTML, the element must end with a slash before the closing angle bracket. Developers can insert a space before the slash to improve backward compatibility with older browsers.
Attributes
Core, internationalization, events, global HTML 5 attributes
align="bottom|left|middle|right|top"Deprecated. Not in HTML 5. Sets image alignment using the following values:
Value
Resulting alignment
bottomAligns the image with the text baseline. This is the default vertical alignment.
leftAligns the image with the containing element’s left edge. Following text can wrap around it.
middleAligns the text baseline with the image’s center.
rightAligns the image with the containing element’s right edge. Following text can wrap around it.
topAligns the image’s top edge with the top of the tallest object on the line.
Table: Possible values of the align attribute on the img element
alt="Text"Required. Provides short alternative text when the image cannot be displayed. Browsers may show it as a tooltip when the pointer is over the image.
border="Zahl"Deprecated. Not in HTML 5. Defines the border width in pixels around a linked image, enclosed in
<a> ... </a>tags.height="Zahl"Specifies the image’s height in pixels. This attribute is optional, but recommended to speed up page rendering.
hspace="Zahl"Deprecated. Not in HTML 5. Defines the space in pixels to leave to the image’s left and right.
ismap(ismap="ismap"in XHTML)Indicates that the image should be used as the basis of a server-side image map (an image containing multiple hyperlinks).
longdesc="URL"Not available in HTML 5. Contains a link to a document with a long description of the image or image map. It can make image information accessible to nonvisual browsers. This attribute is not widely supported.
lowsrc="URL"Not standards-compliant. Refers to an image, usually a smaller file, downloaded before the image specified by the
srcattribute. This was useful when dial-up Internet access was common. It is rarely used today.name="Text"Deprecated in XHTML 1.0. Not in HTML 5. Use instead the attribute
id. Gives the image a name by which scripts or stylesheets can reference it.src="URL"Required. Specifies the location (URL) of the image to display.
usemap="URL"Specifies the location of the coordinates and links for a client-side image map, an image containing multiple hyperlinks.
vspace="Zahl"Deprecated. Not in HTML 5. Specifies the space in pixels to leave above and below the image.
width="Zahl"Specifies the image’s width in pixels. This attribute is optional, but recommended to speed up page rendering.
Example (HTML)
<p>Das ideale Haustier: <img src="schwein.gif" height="200" width="400" alt="Ein Schwein"></p>Example (XHTML)
<p>Das ideale Haustier: <img src="schwein.gif" height="200" width="400" alt="Ein Schwein" /></p>
|
Copyright © 2010 O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "HTML & XHTML ─ kurz & gut" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de