textAlignLast Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:textAlignLast

Description

The textAlignLast property sets how to align the last line of a text, which is only working for elements with the text-align property set to "justify".

Property Values

Value Description
autoDefault value. The last line is justified and aligned left
leftaligned to the left
right aligned to the right
center center-aligned
justify justified as the rest of the lines
start aligned at the beginning of the line
end aligned at the end of the line
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: auto
Return Value: A String, representing the text-align-last property of an element
CSS VersionCSS3

Align the last line of a paragraph to the right:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {//w w w.j  av  a  2 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";  // Standard Syntax
}
</script>

</body>
</html>

Related Tutorials