Style textIndent Property
Example
Indent the first line of a <div> element with 50 pixels:
document.getElementById("myDiv").style.textIndent = "50px";
Try it Yourself »
Description
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.
Browser Support
Property | |||||
---|---|---|---|---|---|
textIndent | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the textIndent property:
object.style.textIndent
Set the textIndent property:
object.style.textIndent = "length|%|initial|inherit"
Property Values
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 |
Technical Details
Default Value: | 0 |
---|---|
Return Value: | A String, representing the indentation of the first line of text in the element |
CSS Version | CSS1 |
More Examples
Example
Return the text indentation of a <div> element:
alert(document.getElementById("myDiv").style.textIndent);
Try it Yourself »
Related Pages
CSS tutorial: CSS Text
CSS reference: text-indent property