Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

CSS | text-indent Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The text-indent property in CSS is used to define the indentation of the first line in each block of text. It also take negative values. It means if the value is negative then the first line will be indented to the left. 

Syntax:

text-indent: length|initial|inherit; 

Property values

  • length: It is used to set fixed indentation in terms of px, pt, cm, em etc. The default value of length is 0. 

Syntax:

text-indent: length;

Example: 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            CSS text-indent Property
        </title>
         
        <!-- CSS text-indent property -->
        <style>
            .sudo {
                text-indent: 70px;
            }
             
            .geeks {
                text-indent: -5em;
            }
             
            .gfg {
                text-indent: 40%;
            }
        </style>
    </head>
     
    <body>
        <h1 style = "">GeeksforGeeks</h1>
        <h2> text-indent Property</h2>
         
        <h2>text-indent: 70px:</h2>
        <div class = "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>
         
        <h2>text-indent: -5em:</h2>
        <div class = "geeks">
            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>
         
        <h2>text-indent: 40%:</h2>
        <div class = "gfg">
            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>
     
    </body>
</html>                   

Output: 

  • percentage (%): It is used to define the indentation in % as compared to the width of the element. 

Syntax:

text-indent: %;

Example: 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            CSS text-indent Property
        </title>
         
        <!-- CSS text-indent property -->
        <style>
            .gfg {
                text-indent: 40%;
            }
        </style>
    </head>
     
    <body>
        <h1 style = "">GeeksforGeeks</h1>
        <h2> text-indent Property</h2>
         
        <h2>text-indent: 40%:</h2>
        <div class = "gfg">
            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>
     
    </body>
</html>                   

Output: 

  • initial: It is used to set text-indent property to its default value. 

Syntax:

text:indent: initial;

Example: 

html




<!DOCTYPE html>
<html>
    <head>
        <title>
            CSS text-indent Property
        </title>
         
        <!-- CSS text-indent property -->
        <style>
            .gfg {
                text-indent: initial;
            }
        </style>
    </head>
     
    <body>
        <h1 style = "">GeeksforGeeks</h1>
        <h2> text-indent Property</h2>
         
        <h2>text-indent: initial:</h2>
        <div class = "gfg">
            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>
     
    </body>
</html>                   

Output: 

Supported Browsers: The browser supported by CSS text-indent property are listed below:

  • Google Chrome 1.0
  • Edge 12.0
  • Internet Explorer 3.0
  • Firefox 1.0
  • Safari 1.0
  • Opera 3.5

My Personal Notes arrow_drop_up
Last Updated : 04 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials