CSS / Reference / text-indent: First-Line Indents and Hanging Paragraphs
Set text-indent: 2em on a paragraph to indent its first line. Positive values move the line start inward and negative values pull it outward. Use padding-inline-start if you want the same inset on every line.
What text-indent values do
| Value | Effect |
|---|---|
0 |
Adds no indent. This is the initial value. |
2em |
Moves the first line inward by twice the font size. |
-2em |
Pulls the first line outward by twice the font size. |
10% |
Resolves against the block container’s own inner size along the inline axis. |
Apply the property to the block that holds the inline text. In horizontal writing, a paragraph with a 200px content width inside a 300px parent indents by 20px when you set text-indent: 10% on that paragraph.
W3C CSS Text definition of text-indent
Compare first-line and whole-paragraph indents
Save the complete example as text-indent-example.html in UTF-8 and open it in a browser. The three boxes use the same text with different CSS declarations. Compare where each line starts relative to the tinted background.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Compare first-line and whole-paragraph indents</title>
<style>
body { margin: 1rem; font: 1rem/1.5 system-ui, sans-serif; }
main { max-inline-size: 18rem; margin-inline: auto; }
.sample { box-sizing: border-box; background: #edf4fc; }
.first { text-indent: 2em; }
.all { padding-inline-start: 2em; }
.hanging { padding-inline-start: 2em; text-indent: -2em; }
</style>
</head>
<body>
<main>
<p>text-indent: 2em</p>
<p class="sample first">Use this paragraph to compare the first line with the following lines. Narrow the window and observe where each line begins as the text wraps onto several lines.</p>
<p>padding-inline-start: 2em</p>
<p class="sample all">Use this paragraph to compare the first line with the following lines. Narrow the window and observe where each line begins as the text wraps onto several lines.</p>
<p>padding-inline-start: 2em + text-indent: -2em</p>
<p class="sample hanging">Use this paragraph to compare the first line with the following lines. Narrow the window and observe where each line begins as the text wraps onto several lines.</p>
</main>
</body>
</html>
Only the first line moves inward in the first paragraph. Every line has the same inset in the second. In the third, the first line meets the start edge, and later lines sit farther in. Set only the third paragraph’s text-indent to 0 to make it match the second, then restore -2em.
Make a hanging indent with a negative value
For a hanging indent, such as in a reference list, reserve space with padding-inline-start: 2em and pull the first line back with text-indent: -2em. If the negative offset is larger than the inset, the first characters can move outside the paragraph and get clipped by an ancestor.
In horizontal writing, padding-inline-start adds space on the left for left-to-right text and on the right for right-to-left text such as Arabic. Physical padding-left leaves the space on the wrong side in a right-to-left paragraph. See the CSS logical properties specification for the mapping. padding-inline-start.
Use hanging and each-line
In browsers that support it, 2em hanging indents every line except the first. 2em each-line indents the first line and each line after a forced break such as <br>. It leaves automatically wrapped lines at their usual starting position.
@supports (text-indent: 2em hanging) {
.hanging {
padding-inline-start: 0;
text-indent: 2em hanging;
}
}
Add this rule at the end of the example’s CSS. Browsers that accept the keyword use it and reset the padding to avoid a double indent. The earlier padding and negative offset still apply in browsers that do not support the keyword.
Troubleshoot unexpected indents
If nothing moves, check that you set the value on the paragraph holding the line. An ordinary inline span does not own that line. If the first characters get cut off, compare the negative value with the start padding and inspect ancestor overflow. Check that every line remains readable at a narrow width.
The property inherits, including to nested blocks and to inline-block buttons inside a paragraph. Set text-indent: 0 on those elements if they should start without the inherited offset.
To set the alignment of text within those lines, see CSS text-align.




