THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Style textIndent Property

Style Object Reference Style Object

Example

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

document.getElementById("myDiv").style.textIndent = "50px";
Try it yourself »

Definition and Usage

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

Internet Explorer Firefox Opera Google Chrome Safari

The textIndent property is supported in all major browsers.


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


Style Object Reference Style Object