You are here: Reference > JavaScript > client-side > HTML DOM > properties > height (embed, iframe, img, table, ...)

height property (embed, iframe, img, table, ...)

Browser support:
Specifies or returns the height of an element.
This property is deprecated. Use the height style property instead.

Syntax:

object.height;
You can find the related objects in the Supported by objects section below.
HTML page for this property: height

Possible values:

Sets or retrieves the height of the object.
One of the following values:
Number(px)
Integer that specifies the height of the object, in pixels.
percentage
Integer in the range 0-100 followed by a %.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the height attribute:
<img id="myImage" src="picture.gif" height="100px" width="100px" />
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<img id="myImage" src="picture.gif" style="height:100px; width:100px;" />
Did you find this example helpful? yes no

Example HTML code 3:

This example illustrates the use of the height property:
<head>
    <script type="text/javascript">
        function SetHeight () {
            var image = document.getElementById ("myImage");
            var input = document.getElementById ("myInput");
            image.height = input.value;                    
        }
    </script>
</head>
<body>
    <img id="myImage" src="picture.gif" height="100px" width="100px" />

    <input id="myInput" type="text" value="50" />
    <button onclick="SetHeight ();">Set image height!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content