Sets or retrieves the calculated width of the object.
= iWidth... >
|Scripting||object.width [ = iWidth ]|
specifies or receives one of the following values.|
|width||Integer that specifies the width of the object in pixels or as a percentage.|
|percentage||String that specifies an integer value followed by a %. The value is a percentage of the width of the parent object.|
The property is read/write.
The property has no default value.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.
If you specify the width property of an img, but not the height property, the resulting height of the img is sized proportionally to the specified width property and the actual height, in pixels, of the source image file. Consider the following example:
|Dimensions of image in source file (pixels):||100 X 50 (W X H)|
|Specified image width:||2in|
|Specified image height:||not specified|
|Resulting image width:||2in|
|Resulting image height:||1in ((50/100) * 2 inches)|
If you specify the width property of an img, and the height and width of the image in the source file are identical, the height of the image matches the width.
If you specify the height property and the width property of an img, the resulting image dimensions match the height and width specified.
When scripting the height property, use either the pixelHeight or posHeight property to numerically manipulate the height value.
If dynamic changes are intended for the height and width, the original values should be set through style (e.g. "style=''height:200px; width:200px'') rather than through the height and width attributes.
Although you can specify the width as a percentage, this property always retrieves the width in pixels.
This example sets the width of the image to 20 pixels regardless of the original size of the image.
<IMG SRC="large.gif" WIDTH="20">
This property is defined in
HTML 4.0 and
is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .