Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Placing an Image on a Web Page

To put an image on a Web page, first move the image file into the same directory folder as the HTML text file. Insert the following HTML tag at the point in the text where you want the image to appear. Use the name of your image file instead of myimage.gif :

<img src="myimage.gif" />

Figure 10.1, for example, inserts several images at the top and bottom of the page. Whenever a Web browser displays the HTML file in Figure 10.1, it will automatically retrieve and display the image files as shown in Figure 10.2.

10fig01.gif

Figure 10.1 Use the <img /> tag to place graphics images on a Web page.

10fig02.jpg

Figure 10.2 When a Web browser displays the HTML page in Figure 10.1, it adds the images named zolzol2.jpg, zolsign.gif, zolzol1.jpg, zolmodel.gif, and zolzol.gif.

If you guessed that img stands for image, you're right; src stands for source, which is a reference to the location of the image file. (As discussed in Hour 1, "Understanding HTML and XML," a Web page image is always stored in a separate file from the text, even though it appears to be part of the same page.)

Just as with the <a href> tag (covered in Hour 3, "Linking to Other Web Pages" ), you can specify any complete Internet address as the <img src> . Alternatively, you can specify just the filename if an image will be located in the same directory folder as the HTML file. You may also use relative addresses such as photos/birdy.jpg or ../smiley.gif .

Share ThisShare This

Informit Network