HTML height Attribute

HTMLWeb DevelopmentFront End Technology

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 −


 Live Demo

<!DOCTYPE html>
<title>HTML DOM Video height</title>
   * {
      padding: 2px;
   form {
      margin: 0 auto;
      text-align: center;
   input[type="button"] {
      border-radius: 10px;
<video id="wordPressIntro" width="320" height="50" controls><source src="" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Video Not Visible">
<div id="divDisplay"></div>
   var divDisplay = document.getElementById("divDisplay");
   var wordPressIntro = document.getElementById("wordPressIntro");
   function getTrackDetails() {
      wordPressIntro.height += 50;
      divDisplay.textContent = 'Video height: '+wordPressIntro.height;

This will produce the following output −

1) Before clicking ‘Video Not Visible’ button −

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

Published on 19-Sep-2019 15:54:31