|
The attributes width and height,
should always be specified if possible in my opinion. This is so that the browser
does not need to wait for the images to load so its size can be determined. If these attributes are specified
then the browser will determine the layout of the web page so that it can first load the Text and the images last. This
gives the reader the opportunity to read the text of web pages while the images load. The dimensions of the images
can be obtained by loading the images into Paint Shop Pro for example. Again these attributes are inserted after
the <img> element as shown below.
<img src="daffy.gif" align="Right
" ALT="Mannan's crazy world"
Width="100
" Height="102" >
It is also possible to control the space around images using the
vspace and hspace
attributes. The vspace attribute controls the vertical space above and below
the image, while the hspace attribute controls the space to the left and right
of the image. These attributes are inserted after the img element as shown
for the other attributes above.
Got to put my hands up here, and say that Netscape has one extra useful attribute that internet explorer has
not. This is the lowsrc attribute. This attribute is dead useful since it allows
the browser to use two images in the same place. This is more clearly seen by examining the following code
<img src="Highres.gif
" Lowsrc="lowres.gif
Width="100
" Height="102
" >
The browser will load the image Lowres.gif on its first layout pass. When all the web content is
loaded it will then load the image Highres.gif in its second pass. This allows you to load up a low resolution
image first, then a high resolution picture afterwards. This is useful if you web pages contain loads of big images
which increases the downloading time. It gives the reader the opportunity to see a low resolution image as he
reads the text, while the high resolution images load. Or you can use this to load two different images in the
same space. You should note that the size of the two images should be the same. If not the browser will scale the
second image to the dimensions of the first image specified in the lowsrc attribute.
Browsers which do not recognize the lowsrc attribute will simply ignore it.
An alternative method based on the above, which will work on all browsers is to load a low resolution, scaled down
image as normal, which you hyperlink to the high resolution full scale image. This allows the reader to decided
if he or she (not being sexist in anyway) wants to see much better image and decreases the downloading time.
The following code illustrates this
- <a href="doggy.gif">
- <img src="crazydog.gif
" Width="100
" Height="102
" ALT="Crazy Dog
" Border="0
" >
- </a>
This will display a scaled down version of the image crazydog.gif, which is hyperlinked to
the image called doggy.gif. Clicking on the image you will open the image
doggy.gif which is an animated gif.Try it.
A good trick to minimise down loading time for your main page.
Finally we move onto some thing a bit more exciting, Image maps. What are those I here you cry? Image
maps are areas of an image which have been pre-defined so that they link to various other documents or even other web sites.
There are two ways of producing image maps. The first is to use the attribute
ISMAP, but this needs the server you are on to have the correct
cgi-bin software installed (this is discussed in more depth later). The alternative method which does not
require any further software is to use the Client Side Image Maps.
To use the client side image maps, we use the attribute
USEMAP in the <img> element. First consider the
following image (mapno.gif), which is simple number bar.

For this image we shall setup an image map so that clicking on the number bar will transport you to the
relevant section of the HTML learning zone. We will make the numbers 2 and 5 of the numberbar so that
they are inactive. The first thing we need to do, is define the image map using the
<Map Name > element. The Html code for the imagemap
i have used for the numberbar is shown below. Notice again that you can use the title attribute to make use of the popup tooltip as shown in the last section.
- <Map Name="Numberbar" >
- <Area shape="RECT" coords="0,0,39,41" href=" section1.html" Title="Link to Section1">
<Area shape="RECT" coords="39,0,78,41" nohref >
<Area shape="RECT" coords="78,0,118,41" href=" section3.html" Title="Link to Section3">
<Area shape="RECT" coords="118,0,158,41" href=" section4.html" Title="Link to Section4">
<Area shape="RECT" coords="158,0,197,41" nohref >
<Area shape="RECT" coords="197,0,236,41" href=" section6.html" Title="Link to Section6">
- </Map>
The <Map Name> element specifies the name of the map so that it can be referred to by the
usemap attribute from any where in the document. I have called the
<Map Name>
simply the Numbarbar.
The Area shape attribute defines the shape of the area of the image
you wish to set up. Currently there are three possible shapes you can define. Theses are
- Rectangle [RECT]
- Circle [CIRCLE]
- Polygon [POLY]
For this particular example I have chosen rectangular shapes since the Numbarbar
has square buttons. To help you understand how the co-ordinate system works, i have placed the image of the
Numbarbar on some graph axis. The first thing you should notice is that,
the co-ordinates are given in pixels, and secondly the origin (ie. (0,0)) is in the top left hand corner.

To define the coords for a rectangle we simply need to define the top left hand corner and the bottom left hand corner of each rectangle, as shown
by the coordinates given in white in the above image. You can use any good graphics package
to obtain the coordinates of the rectangles you wish to define. For example paint shop pro will display the position
of the pointer in the window bar at the bottom of the screen in pixels. Cannot be easier. Now for each region of the image map you have defined, you
need to simply use ther Href attribute to link to the document in question as previously shown. The noref attribute
will ensure that clicking on that particular region of the image, that nothing happens. This is also true for regions of an image which have also not be defined by the area tag.
Now to use this defined image map, you simply add the usemap attribute to the image element as shown below.
<Center>
<img src="mapno.gif
" usemap="#Numberbar
" Width="238
" Height="42
" ALT="NumberBar
" Border="0
" >
<Center>
The above should give us the finished numberbar. Clicking on the respective active areas will link to the relevant sections. Those browsers which support popup tooltips, will also get the extra information placed in the title attribute.

Below is another example of an cartoon image (Micky Mouse), which makes use of an image map to create active links
on parts of the image. Wave that mouse pointer about to locate the three active areas.

You may have noticed that on some websites that you load a page which displays an image but there seems to be no apparent links. Well there is usually an one active link
on the image which is only 1 pixel in dimension. This is a alternative method to password protect certain pages. Only people who know where to find this 1 pixel active link will get to the pages. See if you can locate this 1 pixel link which
I have created just under the number 2 on the number bar. Trust me it does exist.
| |