Language References
Sets or retrieves the calculated width of the object, in pixels.
Inline |
<element width = iWidth [ % ] ... > |
Script |
object.width = iWidth ] |
iWidth |
Integer specifying the width, in pixels. |
iWidth% |
Value expressed as a percentage of the parent object’s width. |
This property is read/write with no default value for the IMG object, and is read-only with no default value for other objects.
Although an author can specify width as a percentage, this property always retrieves the width in pixels.
When specified with the IMG or OBJECT elements, the width attribute tells browsers to override the natural image or object size in favor of these values.
When the object is an image, it is scaled. Browsers should do their best to scale an object or image to match the width specified by the author. Note that widths expressed as percentages are based on the horizontal space currently available, not on the natural size of the image, object, or applet.
When the object is an applet, this attribute specifies the initial width of the applet's display area, excluding any windows or dialogs that the applet creates.
The width attribute gives browsers an idea of the size of an image or object so that they may reserve space for it and continue rendering the document while waiting for the image data.
When used with the TABLE element, this attribute specifies the desired width of the entire table. When the value is a percentage value, the value is relative to the browser's available horizontal space. In the absence of any width specification, table width is determined by the browser.
When used with the COLGROUP element, this attribute specifies a default width for each column in the current column group.
In addition to the standard pixel, percentage, and relative values, this attribute allows the special form "0*" ( zero asterisk ), which means that the width of the each column in the group should be the minimum width necessary to hold the column's contents. This implies that a column's entire contents must be known before its width may be correctly computed. Authors should be aware that specifying "0*" will prevent browsers from rendering a table incrementally.
This attribute is overridden for any column in the column group whose width is specified via a COL element.
When used with the HR element, this attribute specifies the width of the rule. The default width is 100%, the rule extends across the entire canvas.
The following example sets the image's width to 120 pixels regardless of the original size of the image.
<img src="pic.gif" width="120" height="120">
EMBED FRAME IMG MARQUEE OBJECT TABLE VIDEO
height