Latest web development tutorials

HTML DOM Style height property

Style Object Reference Style Objects

Definition and Usage

height property sets or returns the height of the element.

height attribute only play a role in the elements block-level element or an absolute / fixed position. Overflow overflow attribute content may be restricted.

grammar

Setting the height property:

Object.style.height="auto|length|%|inherit"

Back height attributes:

Object.style.height

描述
auto 默认。浏览器设置的高度。
length 使用 px、cm 等单位定义高度。
% 定义高度为父元素的百分比。
inherit height 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support height attributes.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Sets the height of the button:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    document.getElementById("b1").style.height="50px";
}
</script>
</head>
<body>

<input type="button" id="b1" onclick="displayResult()" value="修改按钮高度">

</body>
</html>

try it"


Style Object Reference Style Objects