Learning HTML
Chapter 5 - Using Graphics and Colors

5.3 More Image Tag Features

Using the ALIGN parameter with the settings TOP, MIDDLE, or BOTTOM allows you to set an image next to a single line of text. When the line wraps around, the next line will appear below the image:

This example has the image tag aligned to TOP. The text then wraps around to the next line under the image.

Another option lets you align the text horizontally using RIGHT or LEFT:

 <IMG SRC="up.gif" ALIGN="RIGHT"> In this example...

This appears as:

In this example, the image tag has been aligned to the RIGHT. The text will flow around the image without the extra space that was seen in the previous example.

You will need to be careful using RIGHT and LEFT alignment of images. Because people will be reading your page with different size monitors, images may not appear exactly as you would expect. It is even possible to cause images to overlap when you don't want them to.

Images may also be used with the anchor tags ( <A> </A> ). Placing the IMG tag between the anchor tags makes the image a hypertext link; clicking on the image will take you to the linked document. The following uses the image up.gif as a link to the section of this document named "Top":

 <A HREF="#Top"> <IMG SRC="up.gif"> Go Back </A>

Here is the linked image (try clicking it):

Go Back

When an image becomes a link, the browser places a highlighted border around it. This is useful so you know when images are links; on the other hand, you may feel that the image looks better without a border. The parameter BORDER=0 (the number zero) can be used to eliminate the border:

 <A HREF="#Top"> <IMG SRC="up.gif" BORDER=0> Go Back </A>

You may like this better:

Go Back

Another parameter that is available in the IMG tag is ALT for alternate text. If you are using images as a links or menus, it can be helpful to provide this information for some users. Some browsers (such as Lynx) display text without graphics. In addition, visually impaired users have software that can interpret text (but not images) on a web page. If you do not provide the ALT text, these people will get:

     [IMAGE]

Obviously, this will not be clear without the image. The parameter ALT can be used display alternate text if your viewer is not using graphics or if there is a delay in loading the graphic image.

 <A HREF="#Top"> <IMG BORDER=0 ALT="Go Up" SRC="up.gif"> </A>

This will display the image to someone using a graphical browser like Netscape and the words Go Up to someone using a browser that has not loaded the image. In later versions of some browsers, text specified by the ALT tag appears as a small pop-up box when the cursor is pointed at the image.


Learning HTML
www.dickinson.edu/~dempsey
Last updated 6/8/2001
Copyright © 2001 Paul Dempsey