How To Put Graphics into a Page

A simple TAG can be used to specify the image to be displayed

Since it is often hard to visualize how the combination of text and images will look, you should view the page in progress with your browser to insure you are getting the desired effect.

Tables can be used, as I have here, to provide better control of the layout of images and text.


Basic Image (IMG) Tags

Here is the HTML tag to display the camera graphic. Above each camera is the values of ALIGN used to create the example. The last example here shows the image, which has a transparent background, with a border.

     <IMG SRC="camera.gif" WIDTH=32 HEIGHT=32 BORDER=0 ALIGN="TOP" >Camera

ALIGN=TOP ALIGN=MIDDLE ALIGN=BOTTOM ALIGN=BOTTOM
BORDER=1
Camera Camera Camera Camera

 

You should always specify the WIDTH and HEIGHT for an image. This is because the images are not loaded at the same time as the text of the page. After the browser gets the text, if the HEIGHT and WIDTH parameters are specified for all graphics, the browser can start building and displaying the page. If these values are not provided, the browser has to wait until all graphics are down loaded and it can determine the size of each of the images before it can build and display the page.

If this takes any time, due either the number of graphics or the size of the graphics files, or the loading of the server that is providing the images, the user may get impatient and hit the STOP button before seeing your page. If the text comes up, they may wait it out.

Also, you should always specify an ALT="text" parameter. In case the user hits the STOP button, all the places where graphics would have been have a short title stating what the graphic should have been for that location on the page. Seeing this, they may choose to hit the RELOAD button to get your full page.

This is what you see if the image doesn't load and there is no ALT value. This is what you see if the image doesn't load and there is an ALT="MISSING" value (the ALT message may not be shown for all browsers, though).

When specifying the WIDTH and HEIGHT for an image, you can take advantage of the browser's ability to resize graphics, as shown here. Be careful, though, to maintain the same ratios for the WIDTH and HEIGHT when changing the values or you can distort the image (the third example).

Image with
HEIGHT=32 and WIDTH=32
Image with
HEIGHT=64 and WIDTH=64
Image with
HEIGHT=50 and WIDTH=150

Using LOWSRC to Speed Downloads

Putting a page up before a viewer can be hindered if it takes too long to download the images. If you display only the blank place holders, the viewer may get impatient and STOP or BACK out of your page.

A solution to this is the use of the LOWSRC parameter in the IMG SRC= tag.

For example, the left image below is a gif image that requires 29 KBytes. The right image, created from the original with PaintShop Pro by reducing the image colors, solarizing, and converting it to black and white, reduced the size to only 7 KBytes, which will load considerably faster.


Full image (29 KBytes)

Low source image (7 KBytes)
By specifying the IMG tag as:

<IMG SRC="b2.gif" WIDTH=288 HEIGHT=214 BORDER=0 LOWSRC="b2-16bwsolar.gif">

the smaller sized image will be loaded first. Then, when the rest of the page is loaded, the browser will go back to the server and get the full color image.


Using Tables to Provide Layout Control

Graphics or text can be placed in any cell of a table. The image or text can be positioned just about anywhere in the cell to achieve your desired results. You can add annotation to the left or right or at the top or bottom of the image. In the following, I have set up a one row by two column table to contain two examples that are themselves tables in the cells of the larger table.

In the left set, all images and captions are centered in the cells by using the option ALIGN=CENTER in each of the TD (Table Data, actually the table cell data) tags. In the right set, the images are aligned to the left and right to be closer to the text and the text has ALIGN=RIGHT (for the text at the left) and ALIGN=LEFT (for the text at the right) to bring it closer to the image. The lower right text has VALIGN=BOTTOM set (to align the text in the vertical bottom of the cell as well).

As you can see, you have quite a bit of control of how your graphics and text can be related when you use tables. Other examples using tables are shown on the Tables page.

Text above the image
This is below, vertical aligned to the top of cell
This text is used as a caption to the left of the image
This caption is aligned at the bottom of the cell

Note: This page created another browser window because of the TARGET="_blank" parameter in the <A HREF= ...> tag that got you here. You can simply close this browser to return to the prior page (which is in its own browser window).


Copyright © 1998 Jim Hanson
This Page is the product of Ray Bradbury's Homesite 2.5.

Most recent revision Jan. 7, 1998


This page hosted by GEOCITIES Get your own Free Home Page
1