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 tekst

CSS Reference Manual:text-indent property

Instance

Example 1

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

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

Try it yourself

Example 2

Return 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 Indentation is defined with a length unit. The default value is 0.
% Indentation is defined as a percentage of the parent element's width.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical details

Default value: 0
Return value: A string that represents 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