CSS text-indent property
CSS text-indent Property
Description
The text-indent property defines the indent distance for the first line of text in a block-level element.
Possible Values
- length – Any length value. This property allows negative lengths, which create a “hanging indent” effect.
-
percentage – The first line of text is indented by a distance relative to the width of the element’s containing block.
Applies to
All block-level elements.
DOM Syntax
object.style.textIndent = "20px";
Example
Here is an example showing how to indent the first line of a paragraph:
<html>
<head>
</head>
<body>
<p style = "text-indent:1cm;">
This text will have its first line indented by 1cm </p>
<p style = "text-indent:1cm;">
this line will remain at its actual position this is done by
CSS text-indent property.
</p>
</body>
</html>
will produce the following results −