Video heightProperty

Video 对象参考手册Video Object

Example

Modify the height of the video:

document.getElementById("myVideo").height = "500";

Try it Yourself »

Definition and Usage

The height property is used to set or return the value of the height attribute.

The height attribute describes the height of the video, in pixels.

Tip:It is a good habit to specify the height and width of a video. If these attributes are set, space will be reserved for the video when the page loads. If these attributes are not set, the browser cannot determine the size of the video in advance, and thus cannot reserve suitable space for the video. As a result, the layout will change during page loading.

Note:Do not use the height and width attributes to scale videos! Reducing a video via the height and width attributes only forces users to download the original video (even if it looks smaller on the page). The correct way is to compress the video with software before using it on a web page.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the height attribute.

Note:Internet Explorer 8 and earlier IE versions do not support the <video> element.


Syntax

Return the height property:

videoObject.height

Set the height property:

videoObject.height=pixels

Property Values

Value Description
pixels Describes the height of the video, in pixels (e.g., width="100")

Technical Details

Return Value: A number, representing the height of the video, in pixels.


More Examples

Example

Get the height of the video:

var x = document.getElementById("myVideo").height;
xThe result is:
240

Try it Yourself »


Related Pages

HTML Reference:HTML <video> height attribute


Video 对象参考手册Video Object Other Extensions