HTML | DOM Style textIndent Property
The DOM Style textIndent Property is used for indentation of the first line in each block of text. It also takes negative values. If the value is negative then the first line will be indented to the left.
Syntax:
- It is used to set the textIndent property:
object.style.textIndent = "length|%|initial|inherit"
- It is used to get the textIndent property:
object.style.textIndent
Properties:
- length: It is used to set fixed indentation in terms of px, pt, cm, em etc. The default value of length is 0.
- percentage (%): It is used to define the indentation in % as compared to the width of the element.
- initial: It is used to set text-indent property to its default value.
Return Value: It returns a string value which represent the indentation of the first line in each block of text.
Examples:
<!DOCTYPE html> <html> <head> <title> DOM Style text-indent Property </title> <style> #sudo { text-indent: 40px; } </style> </head> <body> <h1 style = "color:green;">GeeksforGeeks</h1> <h2>DOM Style text-indent Property</h2> <h2>text-indent: 40px:</h2> <div id = "sudo"> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </div> <button type="button" onclick="myGeeks()">Submit</button> <!-- Script to change the textIndent to 120px from 40px--> <script> function myGeeks() { document.getElementById("sudo").style.textIndent = "120px"; } </script> </body> </html> |
Output:
- Before clicking on the button :

- After clicking on button :

Example-2: To get the value of text-indent.
<!DOCTYPE html> <html> <head> <title> DOM Style text-indent Property </title> </head> <body> <h1 style = "color:green;">GeeksforGeeks</h1> <h2>DOM Style text-indent Property</h2> <div id = "sudo" style="text-indent:100px;"> Prepare for the Recruitment drive of product based companies like Microsoft, Amazon, Adobe etc with a free online placement preparation course. The course focuses on various MCQ's & Coding question likely to be asked in the interviews & make your upcoming placement season efficient and successful. </div> <button type="button" onclick="myGeeks()">Submit</button> <script> function myGeeks() { alert(document.getElementById("sudo").style.textIndent); } </script> </body> </html> |
Output:
- Before clicking on the button:

- After clicking on the button:

Supported Browser: The browser supported by DOM Style textIndent are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM Style right Property
- HTML | DOM Style top Property
- HTML | DOM Style maxWidth Property
- HTML | DOM Style borderImageSlice Property
- HTML | DOM Style flexShrink Property
- HTML | DOM Style fontFamily Property
- HTML | DOM Style listStylePosition Property
- HTML | DOM Style paddingLeft Property
- HTML | DOM Style font Property
- HTML | DOM Style borderTopLeftRadius Property
- HTML | DOM Style transitionDelay Property
- HTML | DOM Style columnRuleColor Property
- HTML | DOM Style fontSizeAdjust Property
- HTML | DOM Style fontVariant Property
- HTML | DOM Style textDecorationStyle Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : shubham_singh



