height
Sets the height of the object.
Syntax
{ height:
sHeight }
Possible values
sHeight
Variant that specifies or receives one of the following 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 Length 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. |
The property has a default value of auto. It is not inherited.
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.
When the !DOCTYPE declaration does not specify standards-compliant mode, the height property includes the content box of the object, plus the values of the following properties: border-top, border-bottom, padding-top, and padding-bottom. Subtracting the sum of the values of these properties from the value of the height property gives you the height of the content box of the parent object.
Examples
This example uses an inline style sheet to set the height of an image to 4 centimeters:
<img src="sphere.jpg" style="height:4cm">
This example uses inline scripting to change the height of an image when an onclick event occurs:
<button onclick="height1.style.height='1cm'">Shrink sphere</button>
Standards information
This property is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 and in Cascading Style Sheets (CSS), Level 1 (CSS1) .
Applies to
A, ABBR, ACRONYM, ADDRESS, APPLET, B, BDO, BIG, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CODE, CUSTOM, DD, DEL, DFN, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HN, HR, I, IFRAME, IMG, INPUT TYPE=BUTTON, INPUT TYPE=CHECKBOX, INPUT TYPE=FILE, INPUT TYPE=IMAGE, INPUT TYPE=PASSWORD, INPUT TYPE=RADIO, INPUT TYPE=RESET, INPUT TYPE=SUBMIT, INPUT TYPE=TEXT, INS, LI, OBJECT, OL, OPTION, P, Q, RT, RUBY, S, SELECT, SPAN, SUB, TABLE, TD, TH, TR, TT, U, UL, VAR, XMP
See also
Concepts
width
border-top
border-bottom
padding-top
padding-bottom
Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.