Learning HTML
Chapter 5 - Using Graphics and Colors

5.2 - The Image Tag

The HTML tag for placing images in your document is <IMG> . The required parameter is SRC, which is used to specify the file name. For example, to display the file up.gif, use the following tag:

Here is <IMG SRC="up.gif"> a sample image<P>

This would be displayed as:

Here is a sample image

By default, any text displayed next to an image is aligned with the bottom of the image. Using the ALIGN parameter, you can specify other alignments:

 <IMG SRC="up.gif" ALIGN="TOP"> Text at the top<P>
 <IMG SRC="up.gif" ALIGN="MIDDLE"> Text in the middle<P>

Here's what ALIGN does:

Text at the top

Text in the middle

When using SRC for an image file, you may specify relative or absolute references. This works the same way as the HREF parameter when creating links to other documents (go back to Chapter 4 if you want to review this). In the example above, the file up.gif is a relative reference. This file is in the same directory as the document using it. The following is an example of an absolute references:

<IMG SRC="http://www.bsimple.org/head.gif"> Dare to Be Simple

This refers to a GIF file that is on the www.bsimple.org web server. You can use this SRC reference to insert an image from another computer on your web page. Try it by going back to Notepad and reopening your file second.html. At the end of the document, add the IMG tag shown above and try aligning the text to the middle of the image. Then save your file and view it in Netscape with the File Open command (if you don't remember how, go back to Chapter 2 to review the instructions).


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