3 out of 4 rated this helpful - Rate this topic

height property

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

Sets or retrieves the height of the object.

Syntax

height: height | percentage | auto

Property values

auto

Default.  

height

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 percent sign (%). The value is a percentage of the height of the parent object, which must be specified explicitly. Negative values are not allowed.

CSS information

Applies ToAll elements
Mediavisual
Inheritedno
Initial Value

Remarks

If you specify the height property of an img object but not the width property, the width is proportional to the height according to the dimensions of the image source file.

To perform operations on the numeric value of this property, use pixelHeight or posHeight.

Examples

This example uses an inline style sheet to set the height of an image to 4 centimeters.

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


<img src="sphere.jpg" style="height: 4cm">

This example uses inline scripting to change the height of an image when an onclick event occurs.

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


<button onclick="height1.style.height='1cm'">Shrink sphere</button>

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ