CSS text-indent attribute
- Previous page text-emphasis-style
- Next Page text-justify
Definition
The text-indent property specifies the indentation of the first line of text in a text block.
Comment:Negative values are allowed. If negative values are used, the first line will be indented to the left.
Note:Before CSS 2.1, text-indent always inherited the computed value, not the declared value.
Description
Used to define the indentation of the first line of content in block-level elements. This is most commonly used to create a 'tab' effect. Negative values can be specified, which will produce a 'hanging indentation' effect.
See also:
CSS Tutorial:CSS Text
HTML DOM Reference Manual:textIndent property
Example
Indent the first line of the paragraph by 50 pixels:
p { text-indent:50px; }
CSS syntax
Property value
Value | Description |
---|---|
length | Specifies fixed indentation. Default value: 0. |
% | Specifies indentation based on a percentage of the parent element's width. |
inherit | Specifies that the value of the text-indent property should be inherited from the parent element. |
Technical details
Default value: | not specified |
---|---|
Inheritance: | yes |
Version: | CSS1 |
JavaScript syntax: | object.style.textIndent="50px" |
More examples
- Indent text
- This example demonstrates how to indent the first line of text.
Browser support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | IE / Edge | Firefox | Safari | Opera |
---|---|---|---|---|
1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
- Previous page text-emphasis-style
- Next Page text-justify