Images as Hyperlink Anchors

As explained in Chapter 3, "XHTML 1.0 Element Reference," the <a> container element is used to create hypertext anchors. By clicking the hypertext, you instruct your browser to load the resource at the URL specified in the href attribute of the <a> element.

No law says that hyperlink anchors can only be text. You will often find images serving as anchors, as well. By linking images to other Web pages, you create a button-like effect—the user clicks the button and the browser loads a new page, submits a form, or performs some other action.

To use a graphic as a hyperlink anchor, put the <img /> element that places the graphic inside the <a> element:

 <a href="http://www.warnerbrothers.com/"> <img src="daffy2.gif" width=100 ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 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.