- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set how the last line of a block or a line right before a forced line break is aligned when text-align is "justify" with JavaScript?
Use the textAlignLast property in JavaScript to set the last line to right. Set it to right and allow the right alignment.
Example
You can try to run the following code to return how the last line of a block or a line right before a forced line break is aligned when text-align is "justify" with JavaScript −
<!DOCTYPE html> <html> <head> <style> #myDIV { text-align: justify; } </style> </head> <body> <div id = "myText"> This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. </div> <button onclick = "display()"> Set Alignment </button> <script> function display() { document.getElementById("myText").style.textAlignLast = "right"; ; } </script> </body> </html>
- Related Articles
- Align the last line of the text with CSS
- How to create a line break with JavaScript?
- How to set the type of line in a text-decoration with JavaScript?
- How to set the style of the line in a text decoration with JavaScript?
- How to set the indentation of the first line of text with JavaScript?
- Set the height of a line of text with CSS
- How to use a line break in array values in JavaScript?
- How to divide a string by line break or period with Python regular expressions?
- How to insert a single line break in HTML?
- Break the line and wrap onto next line with CSS
- How to add a line break in an android textView?
- Add line break inside a string conditionally in JavaScript
- How to increase the line thickness of a Seaborn Line?
- How to set the angle of a Line in FabricJS?
- How to set a line color to orange, and specify line markers in Matplotlib?

Advertisements