CSS text-indent Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The text-indent property indents the first line of text in a block element — using length or percentage values.

01

First Line

Indent one line.

02

px Values

Fixed indent.

03

Percentage

Container relative.

04

em Units

Scales with text.

05

Negative

Hanging indents.

06

Paragraphs

Readable blocks.

Introduction

The text-indent property in CSS is used to specify the indentation of the first line of text in a block-level element.

This property allows you to create a visual distinction at the beginning of a paragraph or other block of text, enhancing the readability and visual appeal of your content.

Definition and Usage

Use text-indent on block elements such as <p>, <div>, or <article> when you want only the first line pushed inward. Other lines in the same block stay aligned with the left edge.

💡
Beginner Tip

Start with text-indent: 2em; on paragraphs. The indent scales with font size and looks natural in body copy.

📝 Syntax

The syntax for the text-indent property is simple and can be applied to any block-level element containing text:

syntax.css
element {
  text-indent: length | percentage;
}

Basic Example

text-indent.css
p {
  text-indent: 50px;
}

Syntax Rules

  • Only the first line of the block is indented.
  • Use length values like 50px, 2em, or 1rem.
  • Percentage values are relative to the containing block’s width.
  • Negative values pull the first line left for hanging indent layouts.

Related Properties

  • padding-left — indents the entire block, not just the first line
  • margin-left — shifts the whole element inward
  • text-align — controls horizontal alignment of all lines

🎯 Default Value

The default value of the text-indent property is 0, which means no indentation.

⚡ Quick Reference

QuestionAnswer
Default value0
50px first-line indenttext-indent: 50px;
Scalable indenttext-indent: 2em;
Container-relativetext-indent: 5%;
AffectsFirst line only
InheritedYes

💎 Property Values

The text-indent property accepts length and percentage values.

ValueExampleDescription
lengthtext-indent: 50px;Specifies a fixed length for the indentation. For example, text-indent: 20px; indents the first line by 20 pixels.
percentagetext-indent: 5%;Specifies an indentation as a percentage of the containing block’s width. For example, text-indent: 5%; indents the first line by 5% of the container’s width.
Negative valuetext-indent: -2em;Negative values are also allowed, which will cause the first line to be indented to the left. Often paired with padding-left for hanging indents.
50px 2em 5% -2em

When to Use text-indent

text-indent is the right choice when you want traditional paragraph styling or special first-line layouts:

  • Articles and blogs — Indent the first line of each paragraph for a book-like reading experience.
  • Quotes and citations — Use a small indent to set quoted text apart.
  • Lists with long text — Create hanging indents with negative values and padding.
  • Responsive content — Use em or % so indents scale with layout.

👀 Live Preview

Compare different text-indent values on paragraph text:

No indent — the first line starts at the left edge.
50px indent — the first line starts 50 pixels inward.
8% indent — the first line starts at 8% of the container width.
2em indent — the first line scales with the font size.

Examples Gallery

In this example, we’ll indent the first line of a paragraph by 50 pixels, then explore more indentation patterns.

📜 Basic First-Line Indent

Push the first line inward with fixed and relative values.

Example 1 — 50px paragraph indent

In this example, we’ll indent the first line of a paragraph by 50 pixels.

index.html
<style>
  p {
    text-indent: 50px;
  }
</style>

<h1>Paragraph with Custom Text Indentation</h1>
<p>
  This is an example paragraph. The first line of this paragraph is indented by 50 pixels.
  The text-indent property can be used to create a visual separation between paragraphs,
  making the content easier to read.
</p>
Try It Yourself

How It Works

Only the first line moves 50 pixels to the right. Wrapped lines align with the block’s left edge.

Example 2 — Percentage-based indent

Use a percentage so the indent grows or shrinks with the container width.

percent-indent.css
.article-body p {
  text-indent: 5%;
  line-height: 1.7;
}
Try It Yourself

How It Works

The browser calculates 5% of the parent element’s width and applies that as first-line indent.

📄 Practical Layout Patterns

Use em units for scalable indents and negative values for hanging layouts.

Example 3 — Scalable indent with em

Use 2em so the indent matches roughly two character widths at any font size.

em-indent.css
article p {
  text-indent: 2em;
  font-size: 1.125rem;
}
Try It Yourself

How It Works

em units keep the indent proportional to the element’s font size across headings and body text.

Example 4 — Hanging indent with negative value

Combine a negative text-indent with padding-left so the first line hangs left while other lines stay indented.

hanging-indent.css
.citation {
  padding-left: 2em;
  text-indent: -2em;
}
Try It Yourself

How It Works

Padding pushes the whole block right, then the negative indent pulls the first line back to the left edge.

♿ Accessibility

  • Keep indents moderate — Very large indents can make text harder to scan, especially on mobile.
  • Do not rely on indent alone — Use headings and spacing to structure content for all readers.
  • Test on small screens — Percentage and pixel indents may feel too wide on narrow viewports.
  • Maintain line length — Pair indents with comfortable line-height for readability.

text-indent vs padding and margin

text-indent affects only the first line. Use padding-left when the entire block should move inward, or combine both for hanging indent effects.

indent-comparison.css
/* First line only */
p { text-indent: 2em; }

/* Entire block */
blockquote { padding-left: 1.5rem; }

🧠 How text-indent Works

1

You set an indent value

Apply a length or percentage with text-indent on a block element.

CSS rule
2

The first line shifts inward

Only the first line of the block moves by your chosen amount.

First line
3

Wrapped lines stay aligned

Additional lines in the same block align with the block’s left edge, not the indented first line.

Wrapping
=

Polished paragraph layout

Text blocks look structured and easier to read without affecting every line.

Browser Compatibility

The text-indent property is widely supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is also supported in older versions of these browsers, making it a reliable choice for cross-browser compatibility.

Universal · All modern browsers

Reliable first-line indentation

Chrome, Firefox, Safari, Edge, and Opera all support text-indent in current and many older versions.

99% Browser support
Google Chrome 1+ · Desktop & Mobile
Full support
Mozilla Firefox 1+ · Desktop & Mobile
Full support
Apple Safari 1+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 3.5+ · All versions
Full support

Testing tip

Verify percentage and negative indents on mobile Safari and Chrome at narrow viewport widths.

text-indent property 99% supported

Bottom line: text-indent is one of the most reliable CSS typography properties for paragraph styling.

Conclusion

The text-indent property is a useful tool for web developers looking to enhance the readability and visual appeal of their text content.

By customizing the indentation of the first line of text, you can create a more polished and professional look for your web pages. Experiment with different values and see how this property can improve the presentation of your text.

💡 Best Practices

✅ Do

  • Use 2em for traditional paragraph first-line indents
  • Use % when indents should scale with container width
  • Pair negative indents with padding-left for hanging layouts
  • Test indents on mobile and tablet screen sizes
  • Combine with good line-height for readable paragraphs

❌ Don’t

  • Confuse text-indent with padding-left
  • Use very large pixel indents on narrow screens
  • Indent every heading unless it fits your design system
  • Expect indent to affect inline elements like <span>

Key Takeaways

Knowledge Unlocked

Five things to remember about text-indent

Use these points when styling paragraph text.

5
Core concepts
🔢 02

0 Default

No indent.

Default
📏 03

50px

Fixed indent.

Length
📈 04

5%

Relative width.

Percent
05

Negative

Hanging indent.

Advanced

❓ Frequently Asked Questions

text-indent sets how far the first line of text in a block element is pushed inward from the left edge of the container.
The default value is 0, which means no indentation is applied to the first line.
Yes. A percentage is calculated relative to the width of the containing block, such as text-indent: 5%;.
Yes. Negative values pull the first line to the left, which is useful for hanging indents when paired with padding.
Yes, text-indent is inherited, so setting it on a parent can affect nested block elements.

Practice in the Live Editor

Open the HTML editor and try text-indent: 50px; on a paragraph.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful