Tell a Friend About Our Cool Software

This section describes a few other attributes of the <img> tag that help control images on your Web page.
You use the alt attribute to specify alternate text for the image. This text is displayed in the browser if it is unable to download the image, or if the person visiting your site has images turned off. More importantly, it is used by special software designed to let vision-impaired people surf the Web. A Web page's content is converted to audible speech, and images are converted according to their alt attributes. There is also the benefit of telling search engines and other "screen readers" what the image is and therefore giving them a better idea of what your page is about.
The border attribute defines a border around the image. The default is no
border; set this attribute to a value specifying the border width in pixels.
Here's an <img> tag that uses both the alt and border attributes:
<img src="fish.jpg" border="2" alt="Lake Trout" />
Although it's not used as much anymore, the final <img> tag attribute that I will mention is align. It is used to control the way text wraps around an image when the <img> tag is within a paragraph--that is, between a <p> and a </p> tag along with text.
[[insert NoXHTML_Logo]] The align and border tags are not supported in XHTML. In addition they are deprecated (not recommended) in HTML 4.01.
The default alignment is bottom--the image appears inline with the text
with the text at the bottom and no wrapping, meaning that there are blank
areas to the right and left of the image. You get this result if you do not
include the align attribute in the <img> tag or if you explicitly specify
align="bottom". This is shown in Figure 2-5.
Figure 2-5. The default image alignment provides for no text wrapping.
Setting the align attribute to left places the image against the left edge of
the browser window with the text wrapping in the space to the right of
the image. This is shown in Figure 2.6.
Figure 2-6. Setting the align attribute to left gives this result.
Conversely, setting align to right places the image against the right edge
of the window with the text wrapping in the space to the left of the
image. This is shown in Figure 2.7.
Figure 2-7. Setting the align attribute to right gives this result.
Two other supported values for the align attribute are top and middle. I rarely see these used; you can explore them on your own if you like. We will talk more about the best way to align and add borders to your images using StyleSheets later in Chapter XX.