The text-align-last property in CSS is used to define the alignment of the last line of a text block. It helps in improving the appearance of paragraphs by aligning the final line separately from the rest of the content.
- text-align-last: right; aligns the last line of text to the right side.
- It works on multi-line text elements like <p> tags.
- The property supports values such as left, right, center, and justify.
Syntax:
text-align-last: rightExample:
<!--Driver Code Starts-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>
How to align last line of a
paragraph element to the
right using CSS?
</title>
<!--Driver Code Ends-->
<style>
h1 {
color: green;
}
p {
text-align: justify;
-moz-text-align-last: right;
text-align-last: right;
}
</style>
<!--Driver Code Starts-->
</head>
<body>
<h1>GeeksforGeeks</h1>
<h3>
How to align last line of a
paragraph <br>element to the
right using CSS?
</h3>
<p>
Cascading Style Sheets, fondly referred
to as CSS, is a simply designed language
intended to simplify the process of making
web pages presentable. CSS allows you to
apply styles to web pages. More importantly,
CSS enables you to do this independent of
the HTML that makes up each web page.
</p>
</body>
</html>
<!--Driver Code Ends-->