Javascript Reference - HTML DOM Style textAlignLast Property








The textAlignLast property gets and sets how to align the last line of a text.

Browser Support

textAlignLast Yes No Yes (MozTextAlignLast) Yes Yes

Syntax

Return the textAlignLast property:

var v = object.style.textAlignLast 

Set the textAlignLast property:

object.style.textAlignLast=auto|left|right|center|justify|start|end|initial|inherit

Property Values

auto
Default value. justify and align left for last line
left
last line is aligned left
right
last line is aligned right
center
last line is center-aligned
justify
The last line is justified
start
The last line is aligned at the beginning of the line. Align left if the text-direction is left-to-right, or align right is the text-direction is right-to-left.
end
The last line is aligned at the end of the line.
Align right if the text-direction is left-to-right or
align left is the text-direction is right-to-left.
initial
sets to default value
inherit
Inherits this property from its parent element




Technical Details

Default Value: auto
Return Value: A string representing the text-align-last property
CSS Version CSS3

Example

The following code shows how to align the last line of a paragraph to the right.


<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {<!--from   ww w . j  a v a2  s .  com-->
    text-align: justify; 
}
</style>
</head>
<body>

<div id="myDIV">
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property. You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
You can use the text-align-last property to align the last line of a text, if the text has the text-align property set to justify. This text is where you will see the result of the  text-align-last property.
</div>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    document.getElementById("myDIV").style.MozTextAlignLast = "right"; // Code for Firefox
    document.getElementById("myDIV").style.textAlignLast = "right";
}
</script>
</body>
</html>

The code above is rendered as follows: