Video height attribute
Definition and usage
height
attribute sets or returns the height attribute value.
height
The attribute specifies the height of the video in pixels.
Tip:Always specify the height and width attributes of the video. If height and width are set, the space required by the video is reserved when the page is loaded. However, if these attributes are not present, the browser will not know the size of the video and cannot reserve appropriate space for it. The page layout will change during loading (when the video is loading).
Note:Do not use height and width attributes to resize the video! Shrinking a large video with height and width attributes will force the user to download the original video (even if it looks very small on the page). The correct way to resize the video is to use the program first, and then use it on the page.
Example
Example 1
Change the height of the video:
document.getElementById("myVideo").height = "500";
Example 2
Get the height of the video:
var x = document.getElementById("myVideo").height;
Syntax
Return height attribute:
videoObject.height
Indstil height egenskab:
videoObject.height = pixels
Egenskabsværdi
Værdi | Beskrivelse |
---|---|
pixels | Angiver videoens højde i pixels. |
Tekniske detaljer
Returværdi: | Numerisk værdi, der angiver videoens højde i pixels. |
---|
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |
Relaterede sider
HTML referencer:HTML <video> height egenskab