Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
Sets or retrieves the height of the object.
Syntax
HTML { height: "auto" | length | percentage } Scripting object.style.height [ = sHeight]
Possible Values
The property is read/write with a default value of auto; the CSS attribute is not inherited.
auto Default height. length Floating-point number and an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex). percentage Value expressed as a percentage of the parent object's height.
Remarks
The height of a block object encompasses border-top, border-bottom, padding-top, padding-bottom, margin-top, margin-bottom, and height—the sum of which equals the height of the parent's content.
Percentage values refer to the parent object's height. Negative values are not allowed.
To carry out operations on the numeric value of this property, use pixelHeight or posHeight.
For more information on how to access the dimension and location of objects on the page through the document object model, see Measuring Element Dimension and Location.
Example
The following examples demonstrate use of both the height attribute and the height property to change the height of the object.
The sample below uses an inline style sheet to set an image's height to 4 centimeters.
Sample Code
<IMG SRC="sphere.jpeg" STYLE="height:4cm">This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.![]()
The sample below uses inline scripting to change the image's height on an onclick event.
<BUTTON onclick="height1.style.height='1cm'">Shrink sphere</BUTTON>
Applies To
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.