HTML DOM Style textIndent property
Definition and Usage
textIndent property sets or returns the text of the first line indent.
grammar
Setting textIndent properties:
Object.style.textIndent="length|%|inherit"
Back textIndent properties:
Object.style.textIndent
值 | 描述 |
---|---|
length | 使用 px、cm 等单位定义缩进。默认值是 0。 |
% | 定义缩进为父元素宽度的百分比。 |
inherit | textIndent 属性的值从父元素继承。 |
Browser Support
All major browsers support textIndent property.
Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".
Examples
Examples
Indent text:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("div1").style.textIndent="50px";
}
</script>
</head>
<body>
<div id="div1">
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
</div>
<br>
<button type="button" onclick="displayResult()">缩进文本</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("div1").style.textIndent="50px";
}
</script>
</head>
<body>
<div id="div1">
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
这是一些文本。这是一些文本。
</div>
<br>
<button type="button" onclick="displayResult()">缩进文本</button>
</body>
</html>
try it"
Style Objects