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
[View full width]
The image is now linked, and when clicked on, it will take the visitor to the page. You can even add a title attribute to the link if you want further details about the link to be available to your visitors. By default, browsers place a border around the image to highlight the fact that it is a linked image, and the hand cursor appears upon mouseover, too (see Figure 3-6).
<a href=">
<img src="/image/library/english/10233_photo.jpg" width="250" height="188" alt="photograph of a deliciousVietnamese noodle dish from restaurant Pho 88" />
</a>
Figure 3-6. A linked image.

Example 3-4. Using the border attribute
[View full width]
The image, while still linked, now displays no border (see Figure 3-7).
<a href=">
<img src="/image/library/english/10233_photo.jpg" width="250" height="188" alt="photograph of a deliciousVietnamese noodle dish from restaurant Pho 88" border="0" />
</a>
Figure 3-7. The image, while still linked, has no visible border.

Beware: Borders Are PresentationalThe border attribute is considered presentational because it can be used decoratively. By providing a value greater than 0, the border size changes, whether the image is linked or not. Ideally, you will use CSS instead of the border attribute to modify your borders. CSS will also be used to position or float the image within its content. You'll learn more about this in Chapter 11, "Margins, Borders, and Padding," and Chapter 12, "Positioning, Floats, and Z-index." |