The HTML height attribute is used to declare the height of element (in pixels).
NOTE − As of HTML5 the support to specify height in ‘%’ was removed.
Following elements of HTML have height attribute −
- canvas
- embed
- iframe
- img
- input
- object
- video
Let us see an example of Video height property −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video height</title>
<style>
* {
padding: 2px;
margin:5px;
}
form {
width:70%;
margin: 0 auto;
text-align: center;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Video-height</legend>
<video id="wordPressIntro" width="320" height="50" controls><source src=" https://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Video Not Visible">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var wordPressIntro = document.getElementById("wordPressIntro");
function getTrackDetails() {
wordPressIntro.height += 50;
divDisplay.textContent = 'Video height: '+wordPressIntro.height;
}
</script>
</body>
</html>This will produce the following output −
1) Before clicking ‘Video Not Visible’ button −

2) Clicking ‘Video Not Visible’ button 3 times −
