Style textAlignLast attribute

Definition and usage

textAlignLast This attribute specifies how to align the last line of the text.

Note:textAlignLast This attribute is only applicable when the text-align attribute is set to "justify" elements.

See also:

CSS Reference Manual:text-align-last attribute

Example

Align the last line of the paragraph to the right:

document.getElementById("myDIV").style.textAlignLast = "right";

Try it yourself

Syntax

Return textAlignLast attribute:

object.style.textAlignLast

Set textAlignLast attribute:

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

Attribute value

Value Description
auto

Default value. The alignment rule of each line is determined by the value of text-align.

When the value of text-align is justify, the behavior of text-align-last is the same as setting start.

left Aligns the last line to the left.
right Aligns the last line to the right.
center Centers the last line.
justify Aligns the last line with the other lines (both ends).
start Aligns the last line of the text at the beginning of the line (if the text direction is from left to right, it is aligned to the left, and if the text direction is from right to left, it is aligned to the right).
end Aligns the last line of the text at the end of the line (if the text direction is from left to right, it is aligned to the right, and if the text direction is from right to left, it is aligned to the left).
initial Sets this attribute to its default value. See initial.
inherit Inherits this attribute from its parent element. See inherit.

Technical details

Default value: auto
Return value: string, indicating the element's text-align-last attribute.
CSS version: CSS3

browser supports

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 不支持
请改用
MozTextAlignLast
支持 支持