Javascript examples for CSS Style Property:height
The height property sets or gets the height of an element.
Value | Description |
---|---|
auto | The browser sets the height. This is default |
length | Defines the height in length units |
% | Defines the height in percentage of the parent element |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | auto |
Return Value: | A String, representing the height of an element |
CSS Version | CSS1 |
Set the height of a <button> element:
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/c.png" style="width:100px;height:132px;"> <br> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w. j a v a2 s . c om*/ document.getElementById("myImg").style.height = '20px'; } </script> </body> </html>