HTML | DOM Style height Property
HTML DOM Style height Property is similar to CSS Height Property but it is used to set or get height of an element dynamically.
Syntax :
- To set the height property :
object.style.height = auto|length|initial|inherit;
- To get height property value:
object.style.height
Return Value: String that gives height of the element.
Example-1:
<!DOCTYPE html> <html> <head> <style> p { height: auto; color: white; font-size: 50px; background-color: green; } </style> </head> <body> <br> <button onclick="Play()"> Click to change height </button> <br /> <br /> <script> function Play() { document.getElementById( "block").style.height = "200px" } </script> <p id="block"> Geeks For Geeks </p> </body> </html> |
Output
- Before :

HTML DOM Height Before
- After :

HTML DOM Height after
Example-2:
<!DOCTYPE html> <html> <head> <style> div { height: 10px; background-color: green; width: 100px; } </style> </head> <body> <br> <button onclick="Play()"> Click to increase height of object </button> <br /> <br /> <script> function Play() { document.getElementById("block" ).style.height = "100px" } </script> <center> <div id="block"> </div> </center> </body> </html> |
Output :
- Before :

DOM Height example before
- After :

DOM height after
Supported Browsers: The browser supported by DOM height property are listed below:
- Google Chrome 1.0
- Internet Explorer 4.0
- Firefox 1.0
- Safari 1.0
- Opera
Recommended Posts:
- HTML | Screen height Property
- HTML | DOM Video height Property
- HTML | DOM Object Height Property
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style display Property
- HTML | DOM Style borderBottomColor Property
- HTML | DOM Style animationPlayState Property
- HTML | DOM Style objectPosition Property
- HTML | DOM Style filter Property
- HTML | DOM Style objectFit Property
- HTML | DOM Style transformStyle Property
- HTML | DOM Style flex Property
- HTML | DOM Style margin Property
- HTML | DOM Style backgroundRepeat Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



