Style textIndent Property

Definition and Usage

textIndent Sets or returns the indentation of the first line of text.

Note:Allows negative values. If the value is negative, the first line will be indented to the left.

See also:

CSS Tutorial:CSS Text

CSS Reference Manual:text-indent Property

Example

Example 1

Indents the first line of the <div> element by 50 pixels:

document.getElementById("myDiv").style.textIndent = "50px";

Try It Yourself

Example 2

Returns the text indentation of the <div> element:

alert(document.getElementById("myDiv").style.textIndent);

Try It Yourself

Syntax

Return textIndent Property:

object.style.textIndent

Set textIndent Property:

object.style.textIndent = "length|%|initial|inherit"

Property Value

Value Description
length Defined by a length unit. The default value is 0.
% Defined by the percentage of the parent element's width.
initial Sets this property to its default value. See also initial
inherit Inherits this property from its parent element. See also inherit

Technical Details

Default Value: 0
Return Value: String, indicating the indentation of the first line of text within an element.
CSS Version: CSS1

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support