Attributes for <IMG ...>
WIDTH = "width expression"
HEIGHT = "height expression"
[ Are <IMG ...>WIDTHHEIGHTWIDTHHEIGHTWIDTHHEIGHT
WIDTHHEIGHT
| this code | produces this |
<IMG SRC="starflower.gif" WIDTH=105 HEIGHT=97 ALT="Starflower"> |
![]() |
Are WIDTH and HEIGHT Required?
There is a common misperception that WIDTHHEIGHTWIDTHHEIGHTWIDTHHEIGHTWIDTHHEIGHTALTWIDTHHEIGHTALT
- With
andWIDTHHEIGHT 
- Without
andWIDTHHEIGHT
WIDTHHEIGHTALT
Not the Actual Dimensions
WIDTHHEIGHT
| this code | produces this |
<IMG SRC="starflower.gif" WIDTH=200 HEIGHT=40 ALT="Starflower"> |
|
<IMG SRC="starflower.gif" WIDTH=65 HEIGHT=200 ALT="Starflower"> |
![]() |
Percentages
You can use percentages instead of pixel widths. Percentages are of the available width or height that the image could fill, usually the width or height of the current window. Percentages are useful for creating a "horizontal rule" effect. For example, we can use this image:
<IMG SRC="../graphics/forhr.gif" WIDTH="100%" HEIGHT=8 ALT="--------">
gives us this image:
When you create a psuedo-horizontal-rule this way, set the ALTALT="---------". Also, when using percentages be sure to enclose the value in quotes -- unquoted attribute values cannot include the percent (%) character.
If HEIGHT
<IMG SRC="starflower.gif" WIDTH=105 HEIGHT="50%" ALT="Starflower">
gives us
WIDTH or HEIGHT -- Not Both
It is not defined how a browser should behave if you specify only one of WIDTHHEIGHTWIDTHHEIGHT
| this code | produces this |
<IMG SRC="starflower.gif" WIDTH=30 ALT="Starflower"> |
|
<IMG SRC="starflower.gif" WIDTH=300 ALT="Starflower"> |
![]() |
<IMG SRC="starflower.gif" HEIGHT=50 ALT="Starflower"> |
![]() |
Copyright 1997-2002 Idocs Inc.
