asp.net.ph

Skip Navigation Links

text-indent Attribute | textIndent Property

CSS Attributes Index   Text Attributes


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

Syntax


CSS { text-indent: length | percentage }
Script object.style.textIndent = sIndent ]

Possible Values


length Floating-point number and a valid CSS length unit: either an absolute units designator ( cm, mm, in, pt, pc, or px ) or a relative units designator ( em or ex ).
percentage Value expressed as a percentage of the parent object’s height.

The property is read/write with a default value of 0; the CSS attribute is inherited.

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 example demonstrates the effects of applying different values possible for the CSS text-indent attribute.

 Show me 

The following examples demonstrate use of inline event handlers to dynamically set the indentation of an element’s text. Both methods yield the same effect.

The sample below defines text-indent style attributes in an embedded stylesheet, and invokes calls to the stylesheet to set the indentation in response to mouse events.

<style type="text/css">
<!--
   .normal { text-indent: 25pt }
   .over { text-indent: 20% }
   .click { text-indent: 10em }
-->
</style>
...
<p class="normal" onmouseover="this.className='over'"
   onclick="this.className='click'"
   onmouseout="this.className='normal'">
   ...
</p>

 Show me 

The sample below uses inline event handlers to dynamically set an object’s text indentation in response to mouse events.

<p onmouseover="this.style.textIndent='50pt'"
   onclick="this.style.textIndent='50%'"
   onmouseout="this.style.textIndent=''">
   ...
</p>

 Show me 



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note