aspxtreme

WIDTH Attribute | width Property

HTML Elements/DHTML Objects   Element Attributes


Sets or retrieves the calculated width of the object, in pixels.

Syntax


HTML <ELEMENT WIDTH = sWidth [ % ] ... >
Script object.width [ = sWidth ]

Possible Values


sWidth Integer specifying the width, in pixels.
sWidth% 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.

Remarks

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.

Example

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">
Applies To

COL, COLGROUP, EMBED, FRAME, HR, IMG, MARQUEE, OBJECT, TABLE

See Also

height



Books and more ...

Contents
HTML Elements / DOM Objects
HTML Element Attributes
CSS Attributes
DOM Object Properties
DOM-compliant Events Reference
DOM Methods Reference
DOM Collections Reference
 


Suggested Reading



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme