textJustify style property
Specifies or returns how justified text should be aligned and spaced.
This property has effect only if the value of the textAlign property is set to 'justify'.
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-justify |
Possible values:
The type of this property is string.
One of the following values:
The browser determines the appropriate justification algorithm. | |||||||
Like the newspaper value, except that in East Asian languages (such as Thai) the last line is not justified. | |||||||
Like the newspaper value, except that the last line is also justified. | |||||||
Only content that does not contain any inter-word spacing (such as Asian languages) is justified. | |||||||
Justifies content with ideographic text. | |||||||
Increases the spacing between words. | |||||||
Justifies content by elongating characters. | |||||||
Spacing between letters and words are increased or decreased. |
Default: auto.
Example HTML code 1:
This example illustrates the use of the text-justify property:
|
||||
<head> <style> .lastLeft { text-justify: distribute; text-align: justify; } .lastJustify { text-justify: distribute-all-lines; text-align: justify; } </style> </head> <body> <div class="lastLeft"> The text of the first line is justified alonglonglonglonglonglonglonglonglongword. Next line is justified too alonglonglonglongword. The last line is aligned to left. </div> <br /> <div class="lastJustify"> The text of the first line is justified alonglonglonglonglonglonglonglonglongword. Next line is justified too alonglonglonglongword. The last line is justified too. </div> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the textJustify property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeTextJustify (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the text of the selected option var justifyValue = selectTag.options[whichSelected].text; var div = document.getElementById ("myDiv"); if ('textJustify' in div.style) { div.style.textJustify = justifyValue; } else { alert ("Your browser doesn't support this example!"); } } </script> </head> <body> <div id="myDiv" style="text-align: justify;"> 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-justify value: <br /> <select size="8" onchange="ChangeTextJustify (this);"> <option selected="selected" />auto <option />distribute <option />distribute-all-lines <option />inter-cluster <option />inter-ideograph <option />inter-word <option />kashida <option />newspaper </select> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
imeMode
layoutFlow
layoutGrid
layoutGridChar
layoutGridLine
layoutGridMode
layoutGridType
rubyAlign
rubyOverhang
rubyPosition
textKashidaSpace
unicodeBidi
layoutFlow
layoutGrid
layoutGridChar
layoutGridLine
layoutGridMode
layoutGridType
rubyAlign
rubyOverhang
rubyPosition
textKashidaSpace
unicodeBidi
External links:
User Contributed Comments