See also the Netscape Navigator HTML Tag Reference:   Images and Image Maps


The <img> tag is used to insert images (graphics) into your Web page. The images can be photographs or graphics created from an application. To be compatible with all Web browsers, graphics must be GIFs (.gif) or JPEGs (.jpg).

<img src="photo.jpg">



The width and height of an image can be specified as a percent or as a fixed number of pixels. Every user's screen is divided into a certain number of pixels. The higher a user's screen resolution, the more pixels there are on the user's screen. Larger numbers of pixels allow a user to have the images appear bigger or to have more images fit on the screen.

If only a "width" or "height" attribute is specified with the <img> tag, the Web browser will automatically adjust the opposite dimension to make sure that the image keeps the same proportions.


<img src="photo.jpg" width=200>


<img src="photo.jpg" width=25%>



<img src="photo.jpg" height=200>



To manually adjust the proportions of an image, both the "width" and "height" attributes should be specified. It is often a good idea to specify both the width and height of an image, even if the dimensions given are the same as the actual dimensions of the image. This is so that, while the page and photos are loading, the Web browser will allocate screen space for the photos. While the end result will look the same, this will make the loading of the page and images appear more smooth and less chaotic.

The "alt" attribute can be used to assign a text caption to each image. The caption will show up when the user holds the mouse still over the image. The text will only stay visible for a couple of seconds. With some Web browsers, the text will also appear when the image is first loaded.

<img src="photo.jpg" width=100 height=300 alt="Greg Duffey">
<img src="photo.jpg" width=300 height=100 alt="Redwood's Former Principal">
Greg Duffey Redwood's Former Principal


Keep in mind that HTML can be used to make any graphic as big or as small as you want. However, if you use HTML to display a photo in a larger size than it really is, the picture will become grainy and pixelated. Also, when deciding whether to specify a graphic's width with a fixed number of pixels or a percent, it is probably wise to use pixels for photographs so that they will not become distorted for users with higher screen resolutions. Many graphics, however, will still look acceptable if they are enlarged.


Use the "border" attribute to put a rectangular border around an image. The color of the border will match the current text or font color.

<font color="purple"><img src="photo.jpg" border=5></font>



The horizontal and vertical space next to and above and below images can also be specified as attributes with the <img> tag.

<img src="photo.jpg" hspace=80>
<img src="photo.jpg"><br>
<img src="photo.jpg" vspace=50><br>
<img src="photo.jpg">