ACOM: Web Design Tutorial Site

Click here to return to this site's front page ACOM logo. Click here to return to the ACOM site 

 

Essential related topics

The <IMG> tag

Related topics

Image size

Table attributes


Lesson 5 menu

Subject Index

A-Z Index

Troubleshooting

Resources page

 

HEIGHT and WIDTH

These two attributes are fairly straightforward in themselves, but there are some related issues worth discussing. Therefore, they've been given their own page.

Both attributes take a numeric value that represents a number of pixels on the screen. So, the image below has been produced by the tag which follows it:

Scene from 2001

      <IMG SRC="daveandhal.jpg" ALT="Scene from 2001" HEIGHT=140 WIDTH=275>

You might be thinking, though, isn't that a bit superfluous? Aren't image heights and widths already defined, simply by the size of the actual image file? Well, yes, that's true. But that doesn't mean you always want to go with that pre-defined size. If I use the same tag as above, but without the HEIGHT and WIDTH attributes, the result is as follows:

Scene from 2001

That's the image's "natural state". A smaller (or indeed larger) image might simply look better on the screen. It might be necessary to change the size in order that the image fit in a table cell (see table attributes for more details). Or, you might want to distort the image, by stretching it in one dimension relative to the other, like this:

Scene from 2001

Finally, defining HEIGHT and WIDTH can help a browser lay out a page before the images are downloaded. This is a rather technical point, but it's sometimes better for your readers to not see text "jumping around" while images are being loaded and fitted into place. This particularly applies to pages with a lot of images. If you define these two attributes in all your images the browser will know where to put the text before it loads the images. Although it makes no difference to the functionality of a page, it can make it a slightly friendlier experience to read.

Back to the top

Back to the menu for lesson 5



   

Material on this site is © Drew Whitworth and ACOM, 2002. Permission will usually be given to reproduce material from this site for non-commercial purposes, if credit is given. For enquiries, e-mail Drew at drew@comp.leeds.ac.uk.