September 2, 2000 - Aligning the Last Line | WebReference

September 2, 2000 - Aligning the Last Line

Yehuda Shiran September 2, 2000
Aligning the Last Line
Tips: September 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

There are several ways to align the last line or only line of text in the object. You assign it as follows:

object.style.textAlignLast = sAlignLast;

where sAlignLast is one of:

auto. The default. Last line aligned like other lines in the object, using the value of textAlign.
  • center. Text is centered.
  • inherit. Text is aligned like in the parent object.
  • justify. Text is right justified.
  • left. Text is left-aligned.
  • right. Text is right-aligned. The following paragraph demonstrates several of the above alternatives for aligning a single line of text (in IE 5.5 and above):

    short line short line

    auto center justify left right Here is how we defined the above paragraph and links:

    <P ID="lastLineEffect" STYLE="text-align:justify; text-align-last:auto">
    short line short line
    </P>
    <A HREF="javascript:void(lastLineEffect.style.textAlignLast='auto')">auto</A>
    <A HREF="javascript:void(lastLineEffect.style.textAlignLast='center')">center</A>
    <A HREF="javascript:void(lastLineEffect.style.textAlignLast='justify')">justify</A>
    <A HREF="javascript:void(lastLineEffect.style.textAlignLast='left')">left</A>
    <A HREF="javascript:void(lastLineEffect.style.textAlignLast='right')">right</A></P>

    Notice that the text-align property must be assigned the value of justify for this example to work.