Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at



text-indent 属性 规定了 一个元素 首行 文本内容之前应该有多少水平空格。Horizontal spacing is with respect to the left (or right, for right-to-left layout) edge of the containing block element's box.

适用元素block containers
Percentagesrefer to the width of the containing block
计算值the percentage as specified or the absolute length, plus any keywords as specified
是否适用于 CSS 动画yes, as a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
正规顺序The length or percentage before the keywords, if both are present. If several keywords are present, they appear in the same order as their appearance in the formal grammar.


Formal syntax: <length> | <percentage> && [ hanging || each-line ]
text-indent: 3em       /*  values */
text-indent: 40px
text-indent: 15%       /*  values, relatives to the containing block width */
text-indent: each-line /* keywords values */
text-indent: hanging

text-indent: inherit


Indentation is specified as fixed <length>. Negative values are allowed. See <length> values for possible units.
Indentation is a <percentage> of the containing block width.
Indentation affects the first line of the block container as well as each line after aforced line break, but does not affect lines after asoft wrap break.
Inverts which lines are indented


p { text-indent: 2em } 

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.


Specification Status Comment
CSS Text Level 3
Working Draft Added the hanging and each-line keywords
CSS Transitions
Working Draft Lists text-indent as animatable.
CSS Level 2 (Revision 1)
Recommendation The behavior with display: inline-block and anonymous block boxes have been explicitly defined.
CSS Level 1

Browser compatibility

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support 1.0 (1.7 or earlier) 1.0 3.0 3.5 1.0 (85)
hanging 未实现 未实现 未实现 未实现 未实现
each-line 未实现 未实现 未实现 未实现 未实现
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support 1.0 (1.9.2) ? ? ? ?
hanging 未实现 未实现 未实现 未实现 未实现
each-line 未实现 未实现 未实现 未实现 未实现


 此页面的贡献者: Sebastianz, fscholz, shuaiyunzhang, teoli, sunorry
 最后编辑者: Sebastianz,