Click to return to the DHTML, HTML     
textDecorationUnderline P...     text-justify Attribute | ...     DHTML Properties    
Web Workshop  |  DHTML, HTML & CSS

text-indent Attribute | textIndent Property


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

Syntax

HTML{ text-indent: sIndent }
Scriptingobject.style.textIndent [ = sIndent ]

Possible Values

sIndent String that specifies one of the following values:
lengthFloating-point number, followed by an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex). For more information about the supported length units, see CSS Length Units.
percentageInteger, followed by a %. This value is a percentage of the width of the parent object.

The property is read/write with a default value of 0; the cascading style sheets (CSS) attribute is inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties.

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).

Example

The following examples use the text-indent attribute and the textIndent 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.

Sample Code

<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 feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

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

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

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
BLOCKQUOTE, BODY, BUTTON, CENTER, currentStyle, DD, DFN, DIR, DIV, DL, DT, FIELDSET, FORM, Hn, HR, ISINDEX, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, runtimeStyle, style, TABLE, TD, TH, TR, UL, XMP


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.