CSS

🎯 What is text-indent?

The text-indent property is used to define the amount of space (indentation) at the beginning of the first line in a block of text.

In other words, it moves only the first line of a paragraph inward while keeping the rest of the lines aligned normally.

It is often used in books, articles, or blogs to create a clean and professional paragraph structure.

🔹 Basic Usage

CSS

p {
    text-indent: 40px;
}
                

➡️ In this example, the first line of the paragraph starts 40px inward.

🔹 Values

1. length

Defines indentation using fixed units like px, em, or rem.

CSS

p {
    text-indent: 2em;
}
                

➡️ The first line is indented based on the font size (2 × font size).

2. % (percentage)

Sets indentation relative to the element’s width.

CSS

p {
    text-indent: 10%;
}
                

3. initial

Resets indentation to default value (0).

CSS

p {
    text-indent: initial;
}
                

4. inherit

The element inherits the text-indent value from its parent.

CSS

div {
    text-indent: 30px;
}

p {
    text-indent: inherit;
}
                

➡️ The <p> element inherits the indentation from the parent element.

💡 Summary Table

Value Description
length Fixed indentation (px, em, rem, etc.)
% Relative to element width
initial Resets to default (0)
inherit Inherits from parent element
  • 🧠 Summary

  • The text-indent property controls only the indentation of the first line of text.
  • Common usage examples:
  • 0 → no indentation
  • 50px → clear paragraph indentation
  • This property is especially useful in articles, blogs, and book-style layouts.