Adding Graphics Using the Image Element

The image element in XHTML is considered an inline element. This means that it can be contained within block elements such as paragraphs. It also means that the image will quite literally be rendered "in line," right where the tag is placed within the document. The minimal required syntax for the image element includes two attributes: src for the source URL of the image file, and alt for the alternative text used to describe the image:

<img src="myphoto.jpg" alt="A photo of the author" />

Practically, at least two additional attributes are needed: height and width. These attributes hold the vertical and horizontal measurements of the image, expressed in pixels. When present, these values allow the browser ...

Get XHTML by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.