Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

text-indent — text indentation

text-indent sets the indentation of the first formatted line of text. It does not move the whole block like a margin or add space to every line like padding.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

text-indent: <length-percentage> && hanging? && each-line?;

text-indent applies to block containers and normally indents only the first formatted line. Indentation applies at the line’s logical start edge (inline-start). The line’s inline direction and writing mode determine which physical edge that is, not the direction of an individual text run. For example, in a horizontal right-to-left paragraph, the indent is on the right even if the text is in English. Its initial value is 0; the property is inherited.

Supply a length such as 2em, or a percentage of the container’s inner inline-axis size. Negative values are allowed and can make text overflow the block. The syntax requires a length or percentage; the optional keywords can appear in either order.

each-line includes the first line and lines following forced breaks, but not soft wraps. hanging reverses the selection of lines. Together, they indent soft-wrapped continuations while leaving the first line and lines following forced breaks unindented. A specification definition does not establish support in the target browser.

The example uses only 32px: the expected offset of Alpha is 32px and that of Beta is 0px. A forced break does not normally start another indentation. The example requires local verification.

Examples

<!doctype html>
<meta charset="utf-8">
<title>text-indent</title>
<style>
  p {
    margin: 0;
    padding: 0;
    border: 1px solid;
    width: 320px;
    font: 16px/24px monospace;
    direction: ltr;
    text-align: start;
    text-indent: 32px;
  }
</style>
<p><span id="first">Alpha</span><br><span id="second">Beta</span></p>

Result

Alpha: 32px inline-start offset; Beta: 0px inline-start offset, measured from the paragraph content edge.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources