Indent the first line of a <div> element with 50 pixels:
document.getElementById("myDiv").style.textIndent = "50px";
Try it Yourself »
The textIndent property sets or returns the indentation of the first line of text.
Note: Negative values are allowed. The first line will be indented to the left if the value is negative.
Property | |||||
---|---|---|---|---|---|
textIndent | Yes | Yes | Yes | Yes | Yes |
Return the textIndent property:
object.style.textIndent
Set the textIndent property:
object.style.textIndent
= "length|%|initial|inherit"
Value | Description |
---|---|
length | Defines the indentation in length units. Default value is 0 |
% | Defines the indentation in % of the width of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | 0 |
---|---|
Return Value: | A String, representing the indentation of the first line of text in the element |
CSS Version | CSS1 |
Return the text indentation of a <div> element:
alert(document.getElementById("myDiv").style.textIndent);
Try it Yourself »
CSS tutorial: CSS Text
CSS reference: text-indent property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!