width property (Internet Explorer)

Switch View :
ScriptFree
width property

[This documentation is preliminary and is subject to change.]

Sets or retrieves the width of the object.

Syntax

width: auto | width | percentage

Property values

auto

Default. Default width of the object.

width

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.

percentage

Integer, followed by a %. The value is a percentage of the width of the parent object, whether or not it is specified explicitly. Negative values are not allowed.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value

Remarks

To perform operations on the numeric value of this property, use pixelWidth or posWidth.

For more information about how to access the dimension and location of elements on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Examples

This example uses an inline style sheet to set the width of an image.The following examples use the width attribute and the width property to change the width of the object.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/width_h.htm


<DIV STYLE="position:absolute;top:10px;left:10px;width:1in">
. . . </DIV>

This example uses inline scripting to set the width of an image when an onclick event occurs.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/width_s.htm


<IMG SRC="sphere.jpg" onclick="this.style.width='1cm'"
    ondblclick="this.style.width=''">

See also

CSSStyleDeclaration
currentStyle
runtimeStyle
style
Conceptual
Measuring Element Dimension and Location with CSSOM in Internet Explorer 9
Other Resources
CSS Enhancements in Internet Explorer 6

 

 

Build date: 3/14/2012