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.
Fundamentals
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.
Foundation
📝 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
Defaults
🎯 Default Value
The default value of the text-indent property is 0, which means no indentation.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
0
50px first-line indent
text-indent: 50px;
Scalable indent
text-indent: 2em;
Container-relative
text-indent: 5%;
Affects
First line only
Inherited
Yes
Reference
💎 Property Values
The text-indent property accepts length and percentage values.
Value
Example
Description
length
text-indent: 50px;
Specifies a fixed length for the indentation. For example, text-indent: 20px; indents the first line by 20 pixels.
percentage
text-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 value
text-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.
50px2em5%-2em
Context
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.
Preview
👀 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.
Hands-On
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>
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.
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.
“A hanging indent keeps the first line flush left while wrapped lines stay indented — common in bibliographies and reference lists.”
How It Works
Padding pushes the whole block right, then the negative indent pulls the first line back to the left edge.
A11y
♿ 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.
Companion
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.
Compatibility
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 Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox1+ · Desktop & Mobile
Full support
Apple Safari1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera3.5+ · All versions
Full support
Testing tip
Verify percentage and negative indents on mobile Safari and Chrome at narrow viewport widths.
text-indent property99% supported
Bottom line:text-indent is one of the most reliable CSS typography properties for paragraph styling.
Wrap Up
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.