Linking the Image

Many times you will want to link an image to either another HTML document or a detailed version of the image. In either case, linking an image works the same way as linking text. You surround the image code with the anchor element and the reference to where the image is linking, just as if it were the text content (see Example 3-3).

Example 3-3. Linking the image

<a href="detail.html"><img src="images/photo.jpg" width="250" height="188" alt="photograph of a delicious Vietnamese noodle dish from restaurant Pho 88" /></a>

The image is now linked, and when clicked on, it will take the visitor to the detail.html page. You can even add a title attribute to the link if you want further details about the link to be available ...

Get Spring Into HTML and CSS 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.