textIndent style property
Specifies or returns the horizontal indent for the first line of text.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: text-indent |
Possible values:
The type of this property is string.
One of the following values:
The horizontal indent in length units. For the supported length units, see the length page. | |||||||
The indent is the specified percentage of the width of the parent object. | |||||||
Takes the value of this property from the computed style of the parent element. |
Default: 0.
Example HTML code 1:
This example illustrates the use of the text-indent property:
|
||||
<head> <style> .indent40 { text-indent: 40px; } .indent100 { text-indent: 100px; } </style> </head> <body> <div class="indent40"> This text is indented with 40px from left. It affects only the first line of this block. </div> <br /> <div class="indent100"> This text is indented with 100px from left. It affects only the first line of this block. </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the textIndent property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeTextIndent (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the text of the selected option var indentValue = selectTag.options[whichSelected].text; var div = document.getElementById ("myDiv"); div.style.textIndent = indentValue; } </script> </head> <body> <div id="myDiv" style="border:1px solid #FF0000;"> Pellentesque metus. Sed rhoncus sem quis augue. Phasellus rutrum dui vitae justo tincidunt sollicitudin. Maecenas magna. Mauris nec orci. Nunc laoreet convallis arcu. Aenean diam urna, condimentum et, facilisis luctus, accumsan et, pede. Praesent quam orci, elementum nec, laoreet at, tristique ac, sem. Sed eu tortor vel dolor laoreet vulputate. Pellentesque faucibus diam et libero. Mauris tristique malesu. align last line within the object </div> <br /> Change text-indent value: <br /> <select size="5" onchange="ChangeTextIndent (this);"> <option selected="selected" />0px <option />80px <option />160px <option />240px <option />320px </select> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
color
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textDecoration
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textDecoration
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
External links:
text-indent (MSDN)
text-indent (Mozilla Developer Center)
text-indent (Safari Reference Library)
text-indent (W3C)
text-indent (Mozilla Developer Center)
text-indent (Safari Reference Library)
text-indent (W3C)
User Contributed Comments