Share via


width property

Sets or retrieves the calculated width of the object.

Syntax

HRESULT value = object.put_width( v);HRESULT value = object.get_width(* p);

Property values

Type: long

width

Integer that specifies the width of the object in pixels or as a percentage.

percentage

Not applicable to C++.

Remarks

This property is an integer value. Although an HTML author can specify the width as a percentage, this property always specifies the width in pixels in C++.

If you specify the IHTMLImgElement::width property of an img, but not the IHTMLImgElement::height property, the resulting height of the img is sized proportionally to the specified IHTMLImgElement::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 IHTMLImgElement::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 IHTMLImgElement::height property and the IHTMLImgElement::width property of an img, the resulting image dimensions match the height and width specified.