Open In App

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: 



object.style.textIndent = "length|%|initial|inherit"
object.style.textIndent

Properties:

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:

 

 

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:

Supported Browser: The browser supported by DOM Style textIndent are listed below:


Article Tags :