Javascript examples for CSS Style Property:textIndent
The textIndent property sets or gets the indentation of the first line of text.
Negative values are allowed, which makes the first line indent to the left.
Value | Description |
---|---|
length | Defines the indentation in length units. Default value is 0 |
% | Defines the indentation in percentage of the width of the parent element |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | 0 |
Return Value: | A String, representing the indentation of the first line of text in the element |
CSS Version | CSS1 |
Indent the first line of a <div> element with 50 pixels:
<!DOCTYPE html> <html> <body> <div id="myDiv" style="text-indent:3cm;"> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </div><br> <button type="button" onclick="myFunction()">Return text indentation of div</button> <script> function myFunction() {/*from w w w .jav a 2 s .c o m*/ document.getElementById("myDiv").style.textIndent = '50px'; } </script> </body> </html>