0 out of 3 rated this helpful - Rate this topic

text-indent property

Sets or retrieves the indentation of the first line of text in the object.

This property is not supported for Windows Store apps built for Windows using JavaScript.

CSS 2.1, Section 5.4.7

Syntax

text-indent: <length> | <percentage> | inherit

Property values

A Variant that specifies or receives one of the following values:

length

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px).

percentage

Integer, followed by a percent sign (%). This value is a percentage of the width of the parent object.

inherit

CSS information

Applies ToAll elements
Mediavisual
Inherited1
Initial Value0

Standards information

Remarks

The property can be negative. An indent is not inserted in the middle of an object that was broken by another object, such as br in HTML.

Examples

The following examples use the text-indent attribute and the text-indent property to indent the object's text.

This example uses calls to an embedded style sheet to change the indent on the text when an onclick event occurs. The text was originally indented 2 centimeters using div as a selector in the style sheet.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/text-indent.htm


<STYLE>
    DIV { text-indent:2cm }
    .click1 { text-indent:50% }
    .click2 { text-indent: }
</STYLE>
</HEAD>
<BODY>
<DIV onclick="this.className='click1'"
    ondblclick="this.className='click2'">
. . . </DIV>

This example uses inline scripting to indent the text within the div when an onmouseover event occurs.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/textIndent.htm


<DIV onmouseover=this.style.textIndent="2cm"
:
</DIV>

See also

CSSStyleDeclaration
currentStyle
runtimeStyle
style

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Community Additions

ADD
© 2013 Microsoft. All rights reserved.