CSS Attributes Index Text Attributes
Sets or retrieves the indentation of the text in the object.
CSS |
{ text-indent: length | percentage } |
Script |
object.style.textIndent = sIndent ] |
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.
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 ).
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