Javascript DOM CSS Style height Property

Introduction

Set the height of a <button> element:

document.getElementById("myBtn").style.height = "50px";

View in separate window

<!DOCTYPE html>
<html>
<body>

<button type="button" id="myBtn" onclick="myFunction()">Change the height of this button</button>

<script>
function myFunction() {/*from ww  w.  j a  va2  s.co  m*/
  document.getElementById("myBtn").style.height = "50px";
}
</script>

</body>
</html>

The height property sets or gets the height of an element.

The height property has effect only on block-level elements or on elements with absolute or fixed position.

Property Values

Value Description
autoThe browser sets the height. default
length Defines the height in length units
% Defines the height in % of the parent element
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

The height property returns a String representing the height of an element.




PreviousNext

Related