Panoramic view of QVCC
 

The HTML Lab

Images

The IMG Tag IMG Tag Attributes Image Formats Finding Images Image Properties Dialog

Images make up such an important part of the experience of the web that it is difficult for most people to accept the fact that the ability to display an image wasn't even included in the first version of HTML. Once it was introduced in the person of the <IMG> tag, however, there was no going back. The ability to display, easily, any number of high quality images distinguishes the webpage.

The IMG Tag

Starting Points for Internet Exploration

The IMG tag provide us with the means to display an image. This tag has numerous properties or attributes and there are several restrictions on the kinds of images that are supported. The generic form of the tag, stripped of all it's attributes except the one required attribute, the image source, would look like the following:

    <img src="apple.jpg">

This tag would insert the image "apple.jpg", if it can be found in the current folder, into a webpage at the point where the tag was entered. If the image is not found the browser will most likely display an error placeholder in its place that might display an alternative text message if one exists for the missing image. An example:

Sample Bookmark

This is a missing image.

IMG Tag Attributes

The IMG tag takes a number of attributes which can alter how the image appears or can be used to provide an alternative text-only representation for the image.

On of the things that makes the IMG tag so interesting and useful are the number of attributes it can have as well as the way these attributes can be used to manipulate the image display. A more complete listing for the IMG tag above might look like:

    <img border="0" src="apple.jpg" width="64" height="44" alt="Starting Points">

Here, in addition to the obligatory SRC attribute you can see four of the more common IMG tag attributes. These include:

border
This attribute establishes the width, if any, in pixels of a border that will surround the image. The most common use of a border with an image is to indicate the existence of a hyperlink for the image.
width
The width attribute determines the display width, in pixels, for the image. This is most commonly the actual width of the image but it doesn't have to be. It is quite possible to use the width attribute (along with the height attribute) to make a larger image occupy a smaller space on screen or conversely to have a smaller image occupy a larger part of the screen.
height
The height attribute works in exactly the same manner as the width attribute fixing the size of the screen display for the image. FrontPage and most other webpage software allows changes in one dimension to be automatically applied, in proportion, to the other dimesion thereby keeping the image in scale (see below).
alt
The alt tag is one of several way the IMG tag can be used to provide an alternative source of information for the image. These alternate text display or descriptions might be used in place of a missing image source, or they may provide the content for the mouse tags that appear when you place your mouse over an image. The content of the ALT tag will be spoken aloud by a screen reading program and will be all that display in a text-only browser such as LYNX.

Image Formats

Although certain browsers provide a wider choice of image formats that others the two most universally supported images types for display on the web are the Graphics Image Format, the .GIF, and the Joint Photographers Group format, the .JPG.

The differences between the two formats can be summarized this way: the GIF supports only 256 colors per image although it does support some advance features such as transparency and animation. The JPG on the other hand can have a color palette of millions of colors and it has built in variable compression to reduce the size of the resultant file. Generally a JPG is a better choice for a photo-realistic image (due to the finer gradations of color that it can display) while the GIF is the better choice for small clip art images or where transparency or animation is called for. A GIF will usually be a smaller file that a JPG of the same image.

The following GIF is both transparent and animated (refresh the screen to see the animation)

 
Animated Willimantic Center Logo

 

 

The animated .gif above is a different kind of image from say a JavaScript "rollover". In this form of animated image two images are substituted one for the other as the user passes their mouse over the image. You can see a sample of this by passing your mouse over EARL below.

Earl

This is accomplished by inserting the first image within a hyperlink tag and using the JavaScript "mouseover" event for the hyperlink to switch the contents of the image container (the SRC parameter) to a second (very similar) image that is already loaded into memory. Here's the source code:

First we preload the two images by inserting the following JavaScript within the BODY of our document:

  <script type="text/javascript" language="javascript1.2">
    <!--
    {
      aa=new Image;
      aa.src="earl-1sm.gif";
      bb=new Image;
      bb.src="earl-2sm.gif";
    }
    //-->
  </script>

Next, we insert a empty hyperlink (or you could use a real address if you wish the image to serve up an actual link) and then we use the "onmouseover" and "onmouseout" events to switch images for the image which we have identified as "earlpic". You could of course name the image anything you want but you must uniquely identify the picture for this technique to work.

  <a onmouseover="earlpic.src=bb.src" onmouseout="earlpic.src=aa.src" href="">
    <img border="0" src="earl-1sm.gif" width="158" height="203" id="earlpic" />
  </a>

Finding Images

Where can you obtain images? Well, you can use a digital camera to create some digital photographs or you can use a Paint program like Photoshop or Corel Paint to create your own. You could purchase clip=art collections or find several free collections on the web. Images that appear on the web that are not protected by copyright can be saved to disk by right-clicking on them in the browser and selecting "Save Picture As" in the context menu that pops up. Here are some of the more commonly used QV specific images:

qvcc.gif qv.gif qv.gif apple.jpg

qv.jpg qvcc.jpg

bluebar.gif

 

Image Properties Dialog

Once an image in inserted into a webpage FrontPage will allow you to view and change it's properties by right-clicking on the image and selecting Picture Properties. All of the IMG tag attributes such as border, width, height, and alt can be set from this dialog. The three tabbed dialog box looks like this:

First tab of image properties dialog box.

Second tab of image properties dialog box.

 


last update: 02/26/2004
by: michael lynch

This page contains valid XHTML code.